1. 데이터베이스 생성
$ createdb mydb
2. 데이터베이스 삭제
$ dropdb mydb
3. 데이터베이스 접속
$ psql mydb
4. psql 명령어
mydb=> \h
mydb=> \q
--
abcd ABCD
5. psql 타입
int,
smallint,
real,
double precision,
char(N),
varchar(N),
date,
time,
timestamp,
interval,
geometric type
user-defined data type
6. 대량 데이터 사용
https://www.postgresql.org/docs/14/sql-copy.html
COPY weather FROM '/home/user/weather.txt';
7. 상속
CREATE TABLE cities (
name text,
population real,
elevation int
);
CREATE TABLE capitals (
state char(2) UNIQUE NOT NULL
) INHERITS (cities);
SELECT name, elevation
FROM cities
WHERE elevation > 500;
SELECT name, elevation
FROM ONLY cities
WHERE elevation > 500;