-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextra.sql.txt
More file actions
70 lines (51 loc) · 1.4 KB
/
extra.sql.txt
File metadata and controls
70 lines (51 loc) · 1.4 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
67
68
69
------showing the current user name
show user;
drop table basic_table;
declare
a int;
begin
select count(*) into a from user_tables where table_name = upper('basic_table');
EXCEPTION
WHEN no_data_found THEN
a := 0;
if (a = 1) then
execute immediate q'[drop table basic_table]'; -- executing the command drop table
end if;
end;
/
create table basic_table (
d_roll integer,
d_mark integer
);
-------------proper example of how the transaction actually works for a single user
insert into basic_table values (1,90);
insert into basic_table values (2,95);
commit;
insert into basic_table values (3,84);
SAVEPOINT x_save;
insert into basic_table values (4,75);
insert into basic_table values (5,86);
SAVEPOINT y_save;
insert into basic_table values (6,97);
select * from basic_table;
rollback to x_save;
select *from basic_table;
delete from basic_table;
select *from basic_table;
rollback;
drop table dummy;
create table dummy (
emp_name varchar(20),
joining date
);
insert into dummy values ('wahida',TO_DATE('17-JUN-1987', 'dd-MON-yyyy'));
select LAST_DAY (joining) from dummy;
SELECT emp_name, EXTRACT(Month FROM joining) AS Month
FROM dummy;
select sysdate from dual;
select current_date from dual;
select systimestamp from dual;
SELECT LEAST (TO_DATE ('22-DEC-2007'),TO_DATE ('12-DEC-2008'))
FROM dual;
SELECT GREATEST (TO_DATE ('22-DEC-2007'),TO_DATE ('12-DEC2008'))
from dual;