tags: postgres, database

Connect to docker’s psql

command: docker exec -it <container-name> psql -U user usage: docker exec -it timescaledb psql -U postgres

Create Database

command: create database <databse-name> usage: create database transactions

Select/Switch Database

In the postgres terminal

command: \c database_name usage: \c transactions

Create Table

command:

create table table_name (
	column1 datatype,
	column2 datatype,
	column3 datatype,
);

usage:

create table UserDataSourceCategory (
    UserDataSourceCategoryId INT primary key not null,
    CategoryName text not null,
    CategoryParentId INT,
    foreign key (CategoryParentId) references UserDataSourceCategory(UserDataSourceCategoryId)
);