OSDN Git Service

Regular updates
[twpd/master.git] / postgresql.md
1 ---
2 title: PostgreSQL
3 category: Databases
4 layout: 2017/sheet
5 ---
6
7 ### Console
8
9     $ psql #logs in to default database & default user
10     $ sudo -u <rolename:postgres> psql #logs in with a particular user
11
12 Replace anything within `<placeholder>` accordingly
13
14 ### Commands
15
16  * Show roles: `\du`
17  * Show tables: `\dt`
18  * Show databases: `\l`
19  * Connect to a database: `\c <database>`
20  * Show columns of a table: `\d <table>` or `\d+ <table>`
21  * Quit: `\q`
22
23 ### Creating database
24
25      $ createdb databasename