set 연산 | Set Operation => 둘이 union 호환성이 맞아야 함 = 컬럼수가 같고, 도메인이 호환(타입)되어야 함 --> union, intersect, except -> 중복 제거… 집합연산이라서 중복이 제거됨 -> 중복 허용하려면 union all, intersect all, except all ( ) union ( ) => 합집합 or ( ) intersect ( ) => 교집합 and ( ) except ( ) => 차집합 but not Q) find course_id of courses that ran in Fall 2017 or in Spring 2018 => (select course_id from section where sem = ‘Fall’ and year = ‘2017’) union ( ~~ ) |
null값 | 몇몇 컬럼들에 대해, 튜플이 null값을 가질 수 있음 null = unknown 값 또는 존재하지 않는 값 - null을 포함하는 산술연산의 결과는 다 null임 ( 5 + null = null ) - null <> null, null = null의 결과도 null (unknown) - null값인지를 확인하려면 salary is null is null à null일 때 true - null값이 아닌지를 확인하려면 salary is not null Q) find all instructors whose salary is null => select name from instructor where salary is null - where 절에는 결과가 true / false로 나오는 Boolean 연산자 (and, or, not)가 사용됨 그래서 UNKNOWN 값을 다루기 위해, Boolean 연산자의 정의를 확장한다 - and : ( true and unknown ) = unknown, ( false and unknown ) = false, //하나가 false로 확정이니까 ( unknown and unknown ) = unknown - or : ( true or unknown ) = true, //하나가 true로 확정이니까 ( false or unknown ) = unknown, ( unknown or unknown ) = unknown where 절의 조건이 true로 판정될 때만 해당 레코드를 선택해서, unknown은 false로 간주 |
'데이터베이스설계' 카테고리의 다른 글
[데이터베이스설계] 3-7 having절, 중첩 질의문 (0) | 2024.11.26 |
---|---|
[데이터베이스설계] 3-6 집계함수, group by (0) | 2024.11.25 |
[데이터베이스설계] 3-4 튜플 정렬, where절 술부 (0) | 2024.11.23 |
[데이터베이스설계] 3-3 rename 연산, string 연산 (0) | 2024.11.22 |
[데이터베이스설계] 3-2 where절, from절 (0) | 2024.11.21 |