User Tools

Site Tools


postgres:postgresql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
postgres:postgresql [2009/04/02 16:56] – created devapostgres:postgresql [2011/01/25 07:44] (current) deva
Line 1: Line 1:
 ======PostGreSQL====== ======PostGreSQL======
 +=====Open sql cli interface======
 +<code>
 +psql -U [username] -W [database]
 +</code>
 +
 =====Creating/Deleting users===== =====Creating/Deleting users=====
 <code> <code>
Line 9: Line 14:
 <code> <code>
 createdb -O [owner] -h localhost [dbname] createdb -O [owner] -h localhost [dbname]
 +</code>
 +
 +=====Import/export a database======
 +<code>
 +psql -U [username] -W [dbname] < dump.sql
 +pg_dump -U [username] -h localhost [-t [table]] [dbname] > dump.sql
 +</code>
 +
 +=====Cut prefix from table=====
 +<code>
 +ALTER TABLE data ALTER COLUMN filename TYPE character varying(255) USING substring(filename from 20);
 +</code>
 +
 +=====Find missing foreign key values=====
 +<code>
 +SELECT foo.xcpr FROM (SELECT a.personid AS xcpr, b.personid AS ycpr FROM examinations AS a LEFT OUTER JOIN person AS b ON a.personid = b.personid) AS foo WHERE foo.ycpr IS NULL;
 +</code>
 +
 +=====Disable pager (less/more) in psql=====
 +<code>
 +\pset pager
 </code> </code>
postgres/postgresql.1238684172.txt.gz · Last modified: 2009/04/02 16:56 by deva