Skip to contentSkip to navigationSkip to topbar
On this page
Looking for more inspiration?Visit the
(information)
You're in the right place! Segment documentation is now part of Twilio Docs. The content you are used to is still here—just in a new home with a refreshed look.

Adding Warehouse Users


If you have more than one person working with your Segment Warehouse, you might want to create users for your team so that each person can have a discrete login. The three steps in this section will show you how to create a user, grant usage on a schema and then grant the privileges that the user will need to interact with that schema.


1. Creating a user with the CREATE USER command

1-creating-a-user-with-the-create-user-command page anchor

Create a new user for your team with the CREATE USER(link takes you to an external page) command:

1
CREATE USER <name>
2
[IN GROUP <group>]
3
WITH PASSWORD <password>
4
[VALID UNTIL] <abstime>

The code above in [] is optional, you don't need to group your users or give their credentials an expiration date, the code works without it. However, if you do choose to use those parameters, <abstime> should be formatted in the ISO 8601(link takes you to an external page) format, or '2015-09-13', which translates to September 13th, 2015.

For instance, you can create a user named flashthesloth as:

1
CREATE USER flashthesloth
2
WITH PASSWORD 'slow_is_beautiful'

To get a list of users in your destination, you can run the following SQL code:

SELECT * FROM pg_user

Now that we've confirmed that the user has been created, they already have access to the public schema that contains systems-level information about the cluster. To give them access to the specific schemas that they'll be working in, we'll need to run the GRANT USAGE command.


2. Grant usage on the schema

2-grant-usage-on-the-schema page anchor

Next, you'd need to GRANT USAGE(link takes you to an external page) on the schema to the user we just created:

GRANT USAGE ON SCHEMA <schema_name> TO <user>

The above SQL command grants the user USAGE privileges on a schema. As an example, if you wanted to grant flashthesloth access to your development schema, you'd run the following:

GRANT USAGE ON SCHEMA development TO flashthesloth

Our new user now has usage rights on the development schema. Now, we need to grant the type of SQL commands they'll be able to run against the cluster. For the purposes of this example, we're going to give the user read only privileges.


3. Grant select privileges

3-grant-select-privileges page anchor

To grant your user specific privileges, run the GRANT SELECT(link takes you to an external page) command so the user can query the tables:

GRANT SELECT ON ALL TABLES IN SCHEMA <schema_name> TO <user>

The above SQL command grants the user SELECT rights on all tables in the chosen schema. For our flashthesloth user and the development schema, it would look like below.

GRANT SELECT ON ALL TABLES IN SCHEMA development TO flashthesloth

Completing these three steps results in a new user that can query all the tables in a given schema. If you want to give your user access to more than one schema, repeat steps 2 and 3 for each additional schema. If you have any questions, or if you're running into any issues getting this set up, contact Segment support(link takes you to an external page).