오라클 테이블 생성 명령어 (CREATE/INSERT/ALTER/COMMENT)
CREATE
CREATE TABLE 테이블 ( 컬럼 타입 )
CREATE TABLE 테이블 ( 컬럼 타입 NOT NULL )
1
2
3
4
5
6
7
8
9
10
11
12
13
CREATE TABLE TB_CLIENT_INFO (
CLIENT_ID NUMBER,
CLIENT_NAME VARCHAR2(10),
CLIENT_AGE NUMBER,
CLIENT_GENDER CHAR(1),
CLIENT_BIRTH_DAY DATE NOT NULL,
CLIENT_RSDN NUMBER(13) NOT NULL,
CLIENT_ADDRESS VARCHAR2(100) NOT NULL,
CLIENT_PHONE_NUMBER VARCHAR2(20) NOT NULL,
);
PK
방법 1 : CREATE TABLE 테이블 ( ~~ CONSTRAINT PK이름 KEY (PK컬럼) )
1
2
3
4
5
6
7
CREATE TABLE TB_CLIENT_INFO (
CLIENT_ID NUMBER NOT NULL,
CLIENT_NAME VARCHAR2(10),
CONSTRAINT PK_CLIENT_INFO KEY (CLIENT_ID)
);
방법 2 : ALTER TALBE 테이블 ADD CONSTRAINT PK이름 KEY (컬럼)
1
2
3
4
5
6
7
8
CREATE TABLE TB_CLIENT_INFO (
CLIENT_ID NUMBER NOT NULL,
CLIENT_NAME VARCHAR2(10),
);
ALTER TABLE TB_CLIENT_INFO ADD CONSTRAINT PK_CLIENT_INFO KEY (CLIENT_ID);
INDEX
CREATE INDEX 인덱스명 ON 테이블(컬럼)
1
CREATE INDEX IX_CLIENT_INFO ON TB_CLIENT_INFO(CLIENT_ID);
설명
COMMENT ON TABLE 테이블 IS ‘설명’
COMMENT ON COLUMN 테이블.컬럼 IS ‘설명’
1
2
COMMENT ON TABLE TB_CLIENT_INFO IS '고객정보테이블';
COMMENT ON COLUMN TB_CLIENT_INFO.CLIENT_ID IS '고객ID';
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.