Thursday, January 21, 2010

Quick postgres cheatsheet

You can use '\h' for help on MySQL commands and '\?' for help on postgres commands. '\d' is show tables. It seems to be important that you specify '-h localhost' when logging in - it wouldn't accept my credentials without it.

On ubuntu you need to so the following to get access as 'postgres' (aka root):

sudo -u postgres psql postgres

Create dbase and user:

create database blah;
create user meblah with password 'blah';
grant all on database blah to meblah;

General stuff

psql -U blah -h localhost
\c databasename
select * from tablename;

No comments: