as關(guān)鍵字
as可以用作別名:
select avg(salary) as avg_salary
from instructor
where dept_name = 'Comp. Sci.';
distinct
select count(distinct ID)
from teachers
where semester = 'Spring' and year = 2010;
group by
"找出每個(gè)系在2010年春季學(xué)期講授課程的教師人數(shù)"
select dept_name, count(distinct ID) as instr_count
from instructor natural join teachers
where semester = 'Spring' and year = 2010
group by dept_name;
some
"找出滿足下面條件的所有教師的姓名爹橱,他們的工資至少比Biology系的某一個(gè)教師的工資要高"
select distinct T.name
from instructor as T, instructor as S
where T.salary > S.salary and S.dept_name = 'Biology'
或者
select name
from instructor
where salary > some (select salary
from instructor
where dept_name = 'Biology');
some支持 =, < , > , <=, >=, <>
all
all的用法與some類似
exists not exists
空關(guān)系測(cè)試
unique
重復(fù)元組存在性測(cè)試
關(guān)系范式
簡(jiǎn)單的理解珠叔, 范式即使標(biāo)準(zhǔn)赏陵,衡量數(shù)據(jù)庫(kù)設(shè)計(jì)的規(guī)范等級(jí)泉沾,一般地三椿,考慮到BC范式即可亏娜。
可以參考知乎上的回答https://www.zhihu.com/question/24696366