installation set listen_addresses = 'charlie' in pg_hba.conf: host all all 192.168.1.5 255.255.255.0 trust # Show databases, tables, table desc \l \dt \d table_name # Rename table ALTER TABLE table_name RENAME TO new_table_name; # Replace text UPDATE table_name SET column_name = REPLACE(column_name, 'old_text', 'new_text'); # Create new table from SELECT CREATE TABLE new_table AS SELECT * FROM old_table; # Create a (unique) index CREATE UNIQUE INDEX index_name ON table_name (column1); # Edit a query with $EDITOR \e # Why I like PostgreSQL better When running psql, if you hit Ctrl-C, it doesnt kill the client. Just the last query, or entered string. It accepts only ' as quotes around values, instead of both " and '. Plus, " is used to quote table names. Its a little easier to create users. It's easy to setup the permissions of who can connect. It has some really cool data types. :) Better tab delimited options The pager by default quits on a screen that isn't one page. The pager is turned on by default. # Things that bug me Can't do an export of JUST THE SQL for some reason. (pg_dump) Can't export within a transaction (pg_dump) Can't alter column types, I think :( # sqlite-compat pg_dump pg_dump -t tablename -a -f table.sql -O -x -d database # empty a table, reset primary key TRUNCATE table_name; # Copy data from one table into another INSERT INTO table_one SELECT * FROM table_two ORDER BY table_two.id; # Display indexes \d table_name