Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 665 Bytes

Postgres.md

File metadata and controls

34 lines (27 loc) · 665 Bytes

Postgres

Useful reference

https://www.postgresqltutorial.com/

More useful commands

http://jazstudios.blogspot.com/2010/06/postgresql-login-commands.html

Create and run local Postres docker container

docker run -d --name=postgres -e POSTGRES_USER=mark -e POSTGRES_PASSWORD=password postgres

Login to above docker container

docker exec -it postgres psql -U mark

Show all tables

\dt

Describe a table (use \d+ to get additional info)

\d table_name

Create very basic table with auto-incrementing (SERIAL) primary key

CREATE TABLE mytable (
  id SERIAL PRIMARY KEY
);