User Tools

Site Tools


postgresql

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,usename,procpid,client_addr,waiting,query_start,current_query FROM pg_stat_activity;

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.

  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
postgresql.txt · Last modified: 2017/06/27 07:20 by mihael