REVIEW 3.5 | SQL PART2
:material-circle-edit-outline: 约 231 个字 :fontawesome-solid-code: 26 行代码 :material-clock-time-two-outline: 预计阅读时间 1 分钟
Modification of the Database
update instructor
set salary = salary * 1.3
where salary>1000;
update instructor
set salary = case
where salary <= 1000 then salary *1.5
else salary * 1.2
end
;
Joined Relations
INNER JOIN
与 JOIN
是相同的
User-Defined Types
create type dollaes as numeric (12,2) final -- without ';'
create domain name char(20) not null
constraint name
check (value in table1);
The check clause
Views
create view v(v_name) as (select name ...);
insert into v values(...);
create materialized view v(v_name) as (select name ...);
不是真的对view进行修改,view只是相当于屋子的一个窗口,修改的还是屋子里面的的实际关系
Materialized Views
物化视图和视图的最大区别是它不仅存储定义中的查询语句,而且可以像表一样存储数据。
物化视图和表的最大区别是它不支持 INSERT、UPDATE、DELETE 以及 MERGE 语句,只能通过刷新物化视图进行数据的更新。
物化视图通过提前运行并存储查询结果,通常用于查询优化、数据仓库、数据集成等场景。
Materialized Views相当于创建一个临时表,复制所有满足条件的tuple过来
能加快查询速度,但是需要实时维护
第三节课没听