CREATE USER username WITH PASSWORD 'password'
CREATE DATABASE databasename;
GRANT ALL PRIVILEGES ON DATABASE databasename TO username;
-- Login to the psql shell
psql
-- As super user
psql -U <username> -d <database name user has access to>
-- Basic Shell commands
\l -- List all databases
\q -- Quit psql shell
\? -- Get help
\c databasename -- connect to a database
-- Shell commands for Working with tables
ALTER TABLE tablename RENAME COLUMN columnname TO newcolumnname; -- rename column
ALTER TABLE tablename ALTER COLUMN columnname SET constraint; -- add a column-level constraint
INSERT INTO tablename (columnname1, columnname2) VALUES ('value1', 'value2'); -- enter some data
-- Queries
SELECT * FROM tablename;