vault backup: 2024-09-08 01:58:27f
This commit is contained in:
commit
a4183a1970
15 changed files with 45942 additions and 0 deletions
55
postgres/postgres.md
Normal file
55
postgres/postgres.md
Normal file
|
@ -0,0 +1,55 @@
|
|||
# Postgres Cheatsheet
|
||||
|
||||
### Enter command-line
|
||||
|
||||
```
|
||||
su postgres -c psql
|
||||
```
|
||||
|
||||
### Connect to database
|
||||
|
||||
```
|
||||
\c [db]
|
||||
```
|
||||
|
||||
### List columns in table
|
||||
|
||||
```
|
||||
\d+ [t]
|
||||
```
|
||||
|
||||
### Create database
|
||||
|
||||
```
|
||||
CREATE DATABASE [name];
|
||||
```
|
||||
|
||||
### Create user
|
||||
|
||||
```
|
||||
CREATE USER [name] WITH PASSWORD 'xxx';
|
||||
```
|
||||
|
||||
### Grant all privileges for user to database
|
||||
|
||||
```
|
||||
GRANT ALL PRIVILEGES ON DATABASE [db] TO [user];
|
||||
```
|
||||
|
||||
### Change ownership of database
|
||||
|
||||
```
|
||||
ALTER DATABASE [db] OWNER TO [user];
|
||||
```
|
||||
|
||||
### Show all tables in schema
|
||||
|
||||
```
|
||||
\dt
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Reserved Keywords
|
||||
|
||||
Postgres might complain about an argument being invalid syntax when passing a reserved keyword as argument. Try enclosing the argument in quotation marks.
|
Loading…
Add table
Add a link
Reference in a new issue