How To: Create a new user in PostgreSQL using psql
Instructions provided below describe how to add a new user to a PostgreSQL geodatabase using the psql interactive terminal.
The psql PostgreSQL interactive terminal can be used to create additional users in a PostgreSQL ArcSDE geodatabase. The commands in this How To article will:
- Create a user and assign a password.
- Create a schema for the user if that user will own data within the geodatabase.
- Assign appropriate privileges so that other users can access the data in the newly created user's schema.
This article assumes that PostgreSQL has already been installed, and the ArcSDE for PostgreSQL Post Installation program has been run successfully.
Follow the steps below:
- In Windows, go to:
Start menu > All Programs > PostgreSQL 8.3 > psql to 'postgres'.
This opens up the psql interactive terminal.
- Type the following statement, supplying the desired username and password:
CREATE ROLE username LOGIN PASSWORD 'password' NOINHERIT CREATEDB;
Press the Enter key. This creates a new user login, or ROLE as it is called in postgreSQL, and assigns a password.
- The next step is to create a schema for the new user. This step is necessary only for those users who will own data.
Before creating the schema, connect to the database where the schema will be created. In this example, the database name is sde:
CREATE SCHEMA username AUTHORIZATION username;
Then grant usage on the schema to other users:
GRANT USAGE ON SCHEMA username TO PUBLIC;
- If using a database that is PostGIS enabled, additional privileges must be granted to the user:
GRANT SELECT, INSERT, UPDATE, DELETE ON public.Geometry_columns TO username;
- The new user account is now ready to be used in the PostgreSQL geodatabase.
To exit (quit) from the the PostgreSQL interactive terminal, enter:
and press Enter.
Last Published: 5/5/2016
Article ID: 000010234