- Start and stopping PostGreSQL:
- Start:
brew services start postgresql
- Stop:
brew services stop postgresql
- Restart:
brew services restart postgresql
- Start:
- Accessing PostGreSQL:
- Enter PostGreSQL prompt:
psql postgres
- Connect to a specific database:
psql -d database_name
- Enter PostGreSQL prompt:
- Creating a Database:
- From terminal:
createdb database_name
- From psql prompt:
CREATE DATABASE database_name;
- From terminal:
- Listing Databases:
- From psql prompt: \l or \list
- Connecting to a Database:
- From psql prompt:
\c database_name
- From psql prompt:
- Creating a Table:
CREATE TABLE table_name ( column1 datatype, column2 datatype, ... );
- Listing Tables:
- From psql prompt: \dt
- Describing a Table:
- From psql prompt: \d table_name