본문 바로가기

분류 전체보기90

[데이터베이스설계] 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.
[데이터베이스설계] 3-2 where절, from절 where절Where은 SELECTION σ 와 같은 역할 함, 만족해야 하는 조건을 나타냄 where에는 and, or, not 사용해 연결 가능where에는 비교 연산자들(, >=, =, ) 사용 가능from절From은 카티션 곱 X 과 같음, 쿼리에 포함할 relation들을 열거함. 여러 relation이면 모두 짝짓기, 같은 컬럼명은 앞에 relation 이름을 붙인다 Q) find names of all instructors in the Art department who have taught some course and the course_id=> select name, course_id    from instructor, teaches    where instructor.ID = teache.. 2024. 11. 21.