Basic operation of PostgreSQL
1. Create a user
Postgres=# create user test password 'test'
CREATE ROLE
Note: there is no distinction between user and role in PostgreSQL. "CREATE USER" is an alias for "CREATE ROLE". The two commands are almost identical, except that the user created by the "CREATE USER" command has the LOGIN attribute by default, while the user created by the "CREATE ROLE" command does not have the LOGIN attribute by default.
two。 Create a tablespace
Postgres=# create tablespace tbs owner test location'd:\ postgresql\ data\ tbs'
CREATE TABLESPACE
3. Create a database
Postgres=# create database mydb with owner = test encoding = 'UTF8' tablespace =' tbs'
CREATE DATABASE
4. Authorize the user
Postgres=# grant all on database mydb to test with grant option
GRANT
Postgres=# grant all on tablespace tbs to test
GRANT
5. Connect to the database with the newly created user
D:\ PostgreSQL\ bin > psql-U test mydb
Psql (12.0)
Enter "help" for help.
Mydb= >