-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path23 TWENTYTHREE DAY.sql
More file actions
66 lines (37 loc) · 1.46 KB
/
23 TWENTYTHREE DAY.sql
File metadata and controls
66 lines (37 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
-- view :-
-- it is a vertual table
-- they do not store the data physically but will access the data from the existing table
-- it makes the complex quary easy
-- it will help in security
use regex;
-- types :-
-- COMPLEX --> doesnt allow changes
-- any changes we made in view wont be shown in og table
-- it doesnt allow DML operations
-- we create it by using any function with the columns we want to select
create table newact as
select actor_id,first_name,last_name from sakila.actor where actor_id between 1 and 3;
select * from newact;
create view act_view as
select *,substr(first_name,2) from newact;
select * from act_view;
select * from newact;
insert into newact values(4,'riya','yadav');
select * from act_view;
INSERT INTO act_view values (10,'gola','khatr'); -- error
select * from act_view2;
select * from newact;
-- SIMPLE --> allows changes
-- we can make changes
-- we only use the columns from og table and not any functions
-- changes are reflected in the og table
-- if we used any aggregation ,group by ,having ,union etc in the view then changes made to that view cannot be updated to the main table
select * from newact;
create view act_view2 as
select * from newact;
select * from newact;
insert into newact values(5,'rJ','Tadav');
select * from act_view;
INSERT INTO act_view2 values (6,'rajj','Tagav');
select * from act_view2;
select * from newact;