언어/데이터 베이스
[Sql] Unique 와 Distinct 의 차이점
쟈누
2022. 7. 20. 09:38
반응형
1. 개요
distinct 와 unique 차이를 간단하게 기록해 놓자면
1) distinct
- select 에 사용
- select 시에 출력되는 row 들의 중복된 값을 제거한 나머지 값들을 출력
2) unique
- create table 을 할 때 사용
- 테이블 내에서 unique가 적용된 특정 컬럼의 중복된 값이 insert 되지 않도록 설정
- unique 가 설정된 컬럼에서 중복된 값이 들어갈 경우 error 가 뜨며 값의 유일성 유지
2. 참고 링크
https://learnsql.com/blog/unique-vs-distinct/
What’s the Difference Between UNIQUE and DISTINCT in SQL?
The words UNIQUE and DISTINCT are considered synonyms in our day-to-day life – but not in SQL! Find out why in this article.
learnsql.com
반응형