INSERT 구문은 IDENTITY / CHECK 문제가 주로 나옴
IDENTITY(시작값,증가값)
(Sql Server)
-시작값 : 처음 행이 insert 될 때의 시작값
-증가값 : 다음 행이 insert 될 때 증가되는 값
해당컬럼에 특정값을 insert할 때 오류발생.
예)
TBL_student
student_id Identity (1,1)
student_name NVARCHAR2(3)
INSERT INTO TBL_student VALUES(1,'김하나');
INSERT INTO TBL_student(student_name) VALUES('김두나');
결과)
1,김하나
2,김두나
CHECK(조건)
(Oracle)
-조건을 넣어서 해당 조건만 insert 됨
해당컬럼에 조건 이외의 값이 들어가면 오류
예)
TBL_student
student_higth CHECK(student_higth <180)
student_name NVARCHAR2(3)
INSERT INTO TBL_student VALUES(150,'김하나');
INSERT INTO TBL_student(student_name) VALUES(190,'김두나');
INSERT INTO TBL_student(student_name) VALUES(NULL,'김세나');
결과)
150,김하나
NULL,김세나(NULL값은 출력된다)
'SQLD' 카테고리의 다른 글
[SQLD] 34회 기출문제 오답정리(2) (0) | 2022.10.28 |
---|---|
[SQLD] 34회 기출문제 오답정리(1) (0) | 2022.10.28 |
[SQLD] COALESCE 함수 사용법 (0) | 2022.10.28 |
[SQLD] HASH JOIN / NESTED LOOP JOIN / MERGE JOIN 특징 정리 (0) | 2022.10.28 |
[SQLD]TRUNC/CEIL/FLOOR/ROUND 비교 (0) | 2022.10.20 |