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을 받아오면 됨 - some : 여러 개가 있을 때 어느 하나… 특정되지 않음. --> 최저 1명보다만 높으면 됨 - all : 전부 다. 이러면 전체에서 자기랑 비교해서 작은거 빼야함 |
string 연산 | 문자열을 비교할 수 있는 문자열 매칭 연산자가 포함되어 있음 [ % , _ ] where name like ‘%dar%’ => “dar”가 포함되는 이름들 찾기 // % = 문자열의 길이가 0포함, 0이상 where name like ‘_ _ _%’ => 최소 3 캐릭터인 문자열 찾기 //내용이 뭐든간에 3글자 이상 Q) find the names of all instructors whose name includes the substring “dar” => select name from instructor where name like ‘%dar%’ Q) 100%와 정확히 일치하는 것들만 찾기 – 100%s 이런건 나오지 않게됨 => where name like ‘100\%’ escape ‘\’ - || 이용해서 concatenation, 대소문자 바꾸기, 문자열 길이 찾기, 문자열 일부 추출하기 등… |
'데이터베이스설계' 카테고리의 다른 글
[데이터베이스설계] 3-5 set 연산, null값 (1) | 2024.11.24 |
---|---|
[데이터베이스설계] 3-4 튜플 정렬, where절 술부 (0) | 2024.11.23 |
[데이터베이스설계] 3-2 where절, from절 (0) | 2024.11.21 |
[데이터베이스설계] 3-1 기본 쿼리 구조, select절 (1) | 2024.11.20 |
[데이터베이스설계] 2-10 활용 문제들 (0) | 2024.11.19 |