Skip to content

Commit 85a2c87

Browse files
committed
Update postgres.md
1 parent 8928bbd commit 85a2c87

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

cheatsheets/sql/postgres.md

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,49 @@ logo: postgresql
88

99
- [postgresql.org/docs/](https://www.postgresql.org/docs/)
1010
- [postgresqltutorial.com](https://www.postgresqltutorial.com/)
11+
- [Postgres Cheatsheet](https://www.postgresqltutorial.com/postgresql-cheat-sheet/)
1112

13+
## Show
1214

13-
## Show database
15+
### Show database
1416

1517
```
1618
\l
1719
```
1820

1921
[source](https://www.postgresqltutorial.com/postgresql-show-databases/)
2022

21-
## Login
23+
### Tables
24+
25+
Show all tables.
26+
27+
```
28+
\dt
29+
```
30+
For more info.
31+
```
32+
\dt+
33+
```
34+
35+
Get info on a table.
36+
37+
```
38+
\d+ table_name
39+
```
40+
41+
42+
## Quit
43+
44+
```
45+
\q
46+
```
47+
48+
Or `CTRL`+`d`.
49+
50+
51+
## Users
52+
53+
### Login
2254

2355
Here we use a user named `postgres`.
2456

@@ -34,7 +66,7 @@ postgres=#
3466

3567
This is implied for the rest of this guide.
3668

37-
## Create user
69+
### Create user
3870

3971
```sql
4072
CREATE USER postgres
@@ -46,9 +78,7 @@ CREATE USER foo WITH PASSWORD 'bar';
4678

4779
https://www.postgresql.org/docs/current/app-createuser.html
4880

49-
50-
## Create role
51-
81+
### Create role
5282

5383
```sql
5484
CREATE ROLE foo LOGIN;
@@ -59,8 +89,7 @@ CREATE ROLE admin WITH CREATEDB CREATEROLE;
5989

6090
https://www.postgresql.org/docs/current/sql-createrole.html
6191

62-
63-
## Change password
92+
### Change password
6493

6594
```sql
6695
ALTER USER postgres WITH PASSWORD 'newpass';
@@ -76,7 +105,7 @@ Set it interactively.
76105

77106
https://serverfault.com/questions/110154/whats-the-default-superuser-username-password-for-postgres-after-a-new-install/325596
78107

79-
## List users
108+
### List users
80109

81110
```sql
82111
\du

0 commit comments

Comments
 (0)