PostgreSQL Snippets
Snippets for PostgreSQL.
Table of Contents
DDL
- create/drop database
- create/drop schema
- create/drop table
- create/drop view
- create/drop index
- create/drop trigger
- create/drop enum
DML
- select
- select where
- select order by
- select where order by
- select group by
- select where group by
- select where group by having
- select limit
- insert
- update
- delete
Data Types
- smallint
- integer
- bigint
- decimal
- real
- double precision
- float
- smallserial
- serial
- bigserial
- varchar
- char
- timestamp
- timestamp with time zone
- date
- time
- time with time zone
- boolean
Constraints
- not null
- primary key
- primary key increment
- composite key
- foreign key
- check
- named check
- unique
- named unique
Modify Tables
- add/drop column
- add/drop constraint
- change/drop default
- change data type
- rename column
Alter Statements
- rename database
- change database owner
- rename schema
- change schema owner
- rename table
- change table owner
Database Management
- create role
- alter role
- rename role
- drop role
- grant privileges
- revoke privileges
| |