본 포스팅에서는 SQL에 대해서 정리한다.
1
| CREATE TABLE student AUTHORIZATION id_1354_uname
|
1
2
3
| CREATE DOMAIN sex [AS] VARCHAR(1)
DEFAULT '남'
CONSTRAINT valid_sex CHECK(VALUE IN ('남','여'));
|
1
2
3
4
5
6
7
8
9
10
11
| CREATE TABLE student(
s_id VARCHAR(3) NOT NULL,
major VARCHAR(10),
PW VARCHAR(5),
resion VARCHAR(20),
sex_val sex,
PRIMARY(s_id),
FOREIGN KEY
REFERENCES universe(major_id),
CHECK(성별 = '남');
)
|
1
2
3
4
| CREATE VIEW seoul_persion(name, s_id)
AS SELECT name, s_id
FROM student
WHERE resion = 'seoul';
|
1
2
3
| CREATE UNIQUE INDEX s_id_idx
ON student(s_id DESC, sex ASC)
CLUSTER;
|
1
| ALTER TABLE student ADD grade VARCHAR(1);
|
1
| ALTER TABLE student ALTER s_id VARACHAR(10) NOT NULL;
|
1
| ALTER TABLE student DROP COLUMN grade [CASCADE, RESTRICT]
|
1
2
| DROP CONSTRAINT valid_sex;
DROP INDEX s_id_idx RESTRICT;
|
Comments