PostgreSQL
This commit is contained in:
34
postgresql.md
Normal file
34
postgresql.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# PostgreSQL
|
||||
|
||||
## Interactively create a user
|
||||
|
||||
(Is a `bash` command)
|
||||
|
||||
```
|
||||
# createuser --interactive --pwprompt
|
||||
Enter name of role to add: <USER>
|
||||
Enter password for new role:
|
||||
Enter it again:
|
||||
Shall the new role be a superuser? (y/n) n
|
||||
Shall the new role be allowed to create databases? (y/n) n
|
||||
Shall the new role be allowed to create more new roles? (y/n) n
|
||||
```
|
||||
|
||||
## Create a database
|
||||
|
||||
(Is a `bash` command)
|
||||
|
||||
Also sets the owner
|
||||
|
||||
```
|
||||
# createdb -O <OWNER> <DBNAME>
|
||||
```
|
||||
|
||||
## Commands for the psql shell
|
||||
|
||||
```
|
||||
\l list databases
|
||||
\c <DB> connect to a database
|
||||
\dt list tables
|
||||
\d <TABLE> describe table
|
||||
```
|
||||
Reference in New Issue
Block a user