Differences
This shows you the differences between two versions of the page.
postgresql [2017/06/27 09:20] |
postgresql [2021/04/05 11:23] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== PostgreSQL ====== | ||
+ | |||
+ | ===== Row Id ===== | ||
+ | Each table has a column CTID which holds the row id of a row. | ||
+ | |||
+ | SELECT ctid FROM mytable; | ||
+ | |||
+ | |||
+ | ===== Current Transactions ===== | ||
+ | |||
+ | SELECT datname, | ||
+ | | ||
+ | ===== Exception Join ===== | ||
+ | The exception join can be created with the combination of the left outer join and the query on null. | ||
+ | |||
+ | Table a: | ||
+ | * id | ||
+ | * name | ||
+ | |||
+ | Table b: | ||
+ | * pid | ||
+ | * fid | ||
+ | * longitude | ||
+ | * latitude | ||
+ | |||
+ | Select every entry from table a which has no entry in table b. | ||
+ | |||
+ | <sxh sql> | ||
+ | SELECT * | ||
+ | FROM a LEFT OUTER JOIN b ON (a.id = b.fid) | ||
+ | WHERE b.pid IS NULL | ||
+ | </ | ||
+ | |||
+ | ===== Table Scan Options ===== | ||
+ | |||
+ | set enable_seqscan=true; | ||
+ | set enable_indexscan=true; | ||
+ | |||
+ | ===== Command Line Client ===== | ||
+ | |||
+ | ==== Show Tables ==== | ||
+ | |||
+ | \d | ||
+ | | ||
+ | ==== Show Columns ==== | ||
+ | |||
+ | \d table_name | ||
+ | | ||
+ | ==== Show Databases ==== | ||
+ | | ||
+ | \l | ||
+ | |||
+ | |||
+ | |||