blob: 63b2dc294e797a93c1c0d24632520a3ef2799b87 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
pacman -S postgresql
chmod postgres:postgres /var/lib/postgres
sudo -iu postgres
initdb -D /var/lib/postgres/data
vim data/pg_hba.conf
vim data/postgresql.conf
'''
exit
systemd restart postgres
sudo -iu postgres
'''
createuser user_name
createdb -O db_owner db_name
psql db_name db_user
\du
\l
\c db
\dt
\q
End everything with ;
CREATE DATABASE d
USE d
DROP DATABASE d
CREATE TABLE t(...)
DROP TABLE t
TRUNCATE TABLE t
INSERT INTO t VALUES(...)
SELECT ... FROM t [WHERE ...]
UPDATE t SET ... WHERE ...
DELETE FROM t WHERE ...
ALTER DATABASE name RENAME TO new_name
ALTER DATABASE name OWNER TO new_owner
ALTER TABLE name RENAME TO new_name
ALTER TABLE name SET SCHEMA new_schema
SQL DDL (Date Definition Language) - create, alter, drop, rename, truncate, comment
SQL DQL (Date Query Language) - select
SQL DML (Date Manipulation Language) - insert, update, delete, merge, call, explain plan, lock table
SQL DCL (Date Control Language) - grant, revoke
|