상세 컨텐츠

본문 제목

[오라클 DB 스터디] 제약조건

프로그래밍 도서

by DeepinDev 2025. 4. 21. 08:27

본문

- A NOT NULL constraint prohibits a database value from being null.
- A unique constraint prohibits multiple rows from having the same value in the same column or combination of  columns but allows some values to be null. 
- A primary key constraint combines a NOT NULL constraint and a unique constraint in a single declaration. It prohibits multiple rows from having the same value in the same column or combination of columns and prohibits values from being null.
- A foreign key constraint requires values in one table to match values in another table.
- A check constraint requires a value in the database to comply with a specified condition.
- A REF column by definition references an object in another object type or in a relational table. A REF constraint lets you further describe the relationship between the REF column and the object it references.
  • NOT NULL은 테이블값이 null임을 허용하지 않는다. 
  • Unique 제약조건은 같은 컬럼에서 같은 값을 가지지 못하고 / 컬럼조합에서 같은 값을 가지지 못한다는 규칙이다. 그렇지만 null은 중복되어도 된다. 
  • PK(Primary Key) 제약조건은 NOT NULL제약조건과 Unique제약조건을 조합한 것이다. 그러므로 단일 컬럼이나 컬럼 조합의 테이블 값의 중복을 허용하지 않고, NULL값도 허용하지 않는다. 
  • FK(Foreign Key) 제약조건은 테이블내의 값들을 또 다른 테이블에 맞춰야 한다는 규칙이다. 
  • Check 제약조건은 테이블의 값이 특정조건을 만족해야한다는 규칙이다. 
  • REF 컬럼 제약조건은 해당 컬럼이 다른 객체나 관계테이블을 참조한다는 규칙이다. REF를 통해 REF컬럼과 그 컬럼이 참조하는 다른 객체와의 관계를 더 추가 설명할 수 있다. 

관련글 더보기

댓글 영역