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 |
||
| (One intermediate revision by the same user not shown) | |||
| 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== | ||
| Line 5: | Line 17: | ||
pg_dump -h $HOST -U $USER --dbname $DATABASE -t $TABLE \ | pg_dump -h $HOST -U $USER --dbname $DATABASE -t $TABLE \ | ||
--data-only --column-inserts > $TABLE.sql | --data-only --column-inserts > $TABLE.sql | ||
==Useful links== | |||
* [https://dlt.github.io/blog/posts/introduction-to-postgresql-indexes/ Dalto Curvelano: Introduction to PostgreSQL Indexes] | |||
[[Category:Tech]] | [[Category:Tech]] | ||
Latest revision as of 23:55, 1 March 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