PostgreSQL: Difference between revisions
From Sasara
Jump to navigationJump to search
Created page with "'''Postgres''' is a database. This is a bit of a cheat sheet. ==Export SQL for later insertion== pg_dump -h $HOST -U $USER --dbname $DATABASE -t $TABLE \ --data-only --column-inserts > $TABLE.sql Category:Tech" |
No edit summary |
||
| Line 1: | Line 1: | ||
'''Postgres''' is a database. This is a bit of a cheat sheet. | '''Postgres''' is a database. This is a bit of a cheat sheet. | ||
==Enumerated types== | |||
I generally still prefer tables, but this is quicker/easier. | |||
===Creating=== | |||
CREATE TYPE arch32 AS ENUM ('x86','macppc','sparc','alpha'); | |||
===Listing all properties=== | |||
\dT+ arch32 | |||
===Listing values (simpler)=== | |||
select enum_range(null::arch32); | |||
==Export SQL for later insertion== | ==Export SQL for later insertion== | ||
Latest revision as of 23:43, 17 January 2026
Postgres is a database. This is a bit of a cheat sheet.
Enumerated types
I generally still prefer tables, but this is quicker/easier.
Creating
CREATE TYPE arch32 AS ENUM ('x86','macppc','sparc','alpha');
Listing all properties
\dT+ arch32
Listing values (simpler)
select enum_range(null::arch32);
Export SQL for later insertion
pg_dump -h $HOST -U $USER --dbname $DATABASE -t $TABLE \ --data-only --column-inserts > $TABLE.sql