본문 바로가기

데이터베이스설계33

[데이터베이스설계] 3-5 set 연산, null값 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.. 2024. 11. 24.
[데이터베이스설계] 3-4 튜플 정렬, where절 술부 튜플 정렬하기Ordering the Display of Tuples select distince namefrom instructorwhere TRUEorder by name order by name (asc) => 튜플들을 알파벳 오름차순(디폴트)(123,abc)으로 정렬해 보여줌 order by name desc => 내림차순으로 정렬 order by dept_name, name => 복수개의 컬럼으로 정렬 가능 (앞에꺼로 1차정렬, 겹치는거 대해 2차) order by dept_name asc, name asc 만약 select에 없는 걸 order by에 썼다면, 정렬부터 하고 select하게 됨 (select는 항상 마지막)where절 술부Where 절의 술부 – 범위질의 between, Tupl.. 2024. 11. 23.
[데이터베이스설계] 3-3 rename 연산, string 연산 rename 연산개명 연산 [ as ] rename operation = alias = tuple variable(투플변수) Q) find names of all instructors who have a higher salary than some instructor in ‘Comp.Sci’=> select distinct T.name    from instructor as T, instructor as S                       //as 생략하고, instructor T 해도 됨    where T.salary > S.salary and S.dept_name = ‘Comp.Sci’ dept-name이 Comp인 조건과 자기비교해서 큰거를 모두 충족해야함그리고 그 큰거에 대해 name을 받.. 2024. 11. 22.