PostgreSQL Table
Database
- 물리적인 분리
- 데이터베이스 간
JOIN
불가능
CREATE DATABASE
CREATE DATABASE <database_name> with OWNER <user>
SELECT
\l [<pattern>]
연결
\connect <database_name>
DROP DATABASE
DROP DATABASE <database_name>
Schema
- 논리적인 분리
Table
CREATE TABLE
CREATE TABLE
<table>
(
<column> <type> <constraints>
[,<column> <type> <constraints> ...]
[,<table_constraints> ...]
)
SELECT
\d [<pattern>]
ALTER TABLE
ALTER TABLE
<table>
ADD
COLUMN <column> <data_type> [options]
ALTER TABLE
<table>
DROP
COLUMN <column>
DROP TABLE
TRUNCATE TABLE <table>
DROP TABLE <table>
Record
INSERT INTO
INSERT INTO
<table>
[(
<column>[,
<column>]
)]
VALUES
(
<value>[,
<value>]
)
SELECT
SELECT
<select_expr>
FROM
<table>
[WHERE
<condition>]
UPDATE
UPDATE
<table>
SET
<assignment_list>
[WHERE
<condition>]
DELETE
DELETE FROM
<table>
[WHERE
<condition>]