This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| quickref:postgres [2025-11-04 Tue 14:16] – created theorytoe | quickref:postgres [2026-11-19 Thu 03:33] (current) – demon-machine | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| CREATE DATABASE < | CREATE DATABASE < | ||
| CREATE ROLE < | CREATE ROLE < | ||
| - | ALTER USER backend | + | ALTER USER < |
| - | ALTER USER backend | + | ALTER USER < |
| ALTER DATABASE < | ALTER DATABASE < | ||
| GRANT ALL PRIVILEGES ON DATABASE < | GRANT ALL PRIVILEGES ON DATABASE < | ||
| Line 23: | Line 23: | ||
| UPDATE t SET idcolumn=nextval(' | UPDATE t SET idcolumn=nextval(' | ||
| </ | </ | ||
| + | |||
| + | ===== Add/Drop Constraint ===== | ||
| + | Postgres names constraints on table creation in the following format: '' | ||
| + | <code sql> | ||
| + | ALTER TABLE < | ||
| + | ALTER TABLE < | ||
| + | </ | ||
| + | |||
| + | ===== Backup / Restore ===== | ||
| + | < | ||
| + | # Dump full db | ||
| + | pg_dump -U < | ||
| + | |||
| + | # Table, schema, or data only | ||
| + | pg_dump -U < | ||
| + | pg_dump -U < | ||
| + | pg_dump -U < | ||
| + | |||
| + | # Custom format (restore with pg_restore) | ||
| + | pg_dump -U < | ||
| + | |||
| + | # Restore | ||
| + | psql -U < | ||
| + | pg_restore -U < | ||
| + | </ | ||
| + | |||