-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass 17.sql
More file actions
59 lines (46 loc) · 1.41 KB
/
class 17.sql
File metadata and controls
59 lines (46 loc) · 1.41 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
-- tcl (transaction conyral language)
-- transaction - logical statement
-- control / managment
create database testing12;
use testing12;
create table xyz(id int , name varchar(20));
insert into xyz values(11,'aman') ,( 12,'user') ;
select * from xyz ;
start transaction;
insert into xyz values(99 , 'hardik');
select * from xyz;
commit;
start transaction;
SET sql_safe_updates = 0 ; -- safe mode disable
delete from xyz ;
select * from xyz;
rollback; -- revert the transaction
start transaction;
SET sql_safe_updates = 0 ; -- safe mode disable
insert into xyz values(1001, 'adfet');
select * from xyz;
start transaction;
update xyz set name = "hardik ";
savepoint hardik_savepoint;
insert into xyz values(12391239123 , 'fhwefh');
rollback to hardik_savepoint ;
select * from xyz;
with recursive cte as (
select emp.employeeid , emp.employeename , emp.employeename as managerchain
from employees as emp
where emp.managerid is null
union
select emp.employeesid , emp.employeename ,
concat ( mgr.managerchain , '=>', emp.employeename) as managerchain
from employees as emp
join cte as mgr on emp.managerid= mgr.employeeid )
select * from cte ;
-- transaction
/*
transaction start
ddl , dml
transaction end
1) autocommit => disable/ write (start transaction )
3) end (commit ; rollback ; ddl statment )
commit - is the transcation of tcl it pramanently save transation
rollback - it is use to discrat in the data changes