Postgres: Difference between revisions
Appearance
mNo edit summary |
mNo edit summary |
||
| Line 1: | Line 1: | ||
== PostgreSQL data types == | == PostgreSQL data types == | ||
{| class="wikitable" | |||
|+ | |||
!Type | |||
!min | |||
!max | |||
!comment | |||
|- | |||
|boolean | |||
| | |||
| | |||
| | |||
|- | |||
|char(n) | |||
| | |||
| | |||
| | |||
|- | |||
|varchar(n) | |||
| | |||
| | |||
| | |||
|- | |||
|text | |||
| | |||
| | |||
| | |||
|- | |||
|smallint | |||
| -32768 | |||
|32767 | |||
| | |||
|- | |||
|int | |||
| | |||
| | |||
| | |||
|- | |||
|serial | |||
| | |||
| | |||
|(~auto_increment in mysql) | |||
|- | |||
|float(n) | |||
| | |||
| | |||
| | |||
|- | |||
|real / float8 | |||
| | |||
| | |||
| | |||
|- | |||
|numeric(p,s) | |||
| | |||
| | |||
| | |||
|- | |||
|date | |||
| | |||
| | |||
| | |||
|- | |||
|time | |||
| | |||
| | |||
| | |||
|- | |||
|timestamp | |||
| | |||
| | |||
| | |||
|- | |||
|timestamptz | |||
| | |||
| | |||
| | |||
|- | |||
|interval | |||
| | |||
| | |||
| | |||
|- | |||
|json | |||
| | |||
| | |||
| | |||
|- | |||
|jsonb | |||
| | |||
| | |||
| | |||
|- | |||
|uuid | |||
| | |||
| | |||
| | |||
|- | |||
| + special | |||
| | |||
| | |||
|} | |||
== List all databases == | == List all databases == | ||
Revision as of 18:54, 29 September 2024
PostgreSQL data types
| Type | min | max | comment |
|---|---|---|---|
| boolean | |||
| char(n) | |||
| varchar(n) | |||
| text | |||
| smallint | -32768 | 32767 | |
| int | |||
| serial | (~auto_increment in mysql) | ||
| float(n) | |||
| real / float8 | |||
| numeric(p,s) | |||
| date | |||
| time | |||
| timestamp | |||
| timestamptz | |||
| interval | |||
| json | |||
| jsonb | |||
| uuid | |||
| + special |
List all databases
SELECT datname FROM pg_database WHERE datistemplate = false;
List all tables
SELECT table_catalog,table_schema,table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema = 'public' ORDER BY table_type, table_name