-
Notifications
You must be signed in to change notification settings - Fork 0
/
week5.txt
117 lines (82 loc) · 4.02 KB
/
week5.txt
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
DBMS EXPT - 5
S.SARAN KIRTHIC
RA1911032010041
SQL> create table bookings
2 (
3 sno varchar(25),
4 name varchar(25),
5 days number(10),
6 nights number(10),
7 primary keey(sno));
primary keey(sno))
*
ERROR at line 7:
ORA-00907: missing right parenthesis
SQL> create table bookings(sno varchar(20), name varchar(20), days number(10), nights number(10), primary key(sno));
Table created.
SQL> insert into bookings values('11','randy',4,3);
1 row created.
SQL> insert into bookings values('12','jim',2,2);
1 row created.
SQL> insert into bookings values('13','sam',3,3);
1 row created.
SQL> select * from bookings;
SNO NAME DAYS NIGHTS
-------------------- -------------------- ---------- ----------
11 randy 4 3
12 jim 2 2
13 sam 3 3
SQL> create table bill(sno varchar(20),bill varchar(10),foreign key(sno) references bookings(sno));
Table created.
SQL> desc bill;
Name Null? Type
----------------------------------------- -------- ----------------------------
SNO VARCHAR2(20)
BILL VARCHAR2(10)
SQL> insert into bookings values('&sno','&name','&days','&nights');
Enter value for sno: 13
Enter value for name: ricky
Enter value for days: 3
Enter value for nights: 4
old 1: insert into bookings values('&sno','&name','&days','&nights')
new 1: insert into bookings values('13','ricky','3','4')
insert into bookings values('13','ricky','3','4')
*
ERROR at line 1:
ORA-00001: unique constraint (RA1911032010041.SYS_C006236) violated
SQL> select * from bookings;
SNO NAME DAYS NIGHTS
-------------------- -------------------- ---------- ----------
11 randy 4 3
12 jim 2 2
13 sam 3 3
SQL> insert into bookings values('&sno','&name','&days','&nights');
Enter value for sno: 14
Enter value for name: john
Enter value for days: 6
Enter value for nights: 7
old 1: insert into bookings values('&sno','&name','&days','&nights')
new 1: insert into bookings values('14','john','6','7')
1 row created.
SQL> select * from bookings;
SNO NAME DAYS NIGHTS
-------------------- -------------------- ---------- ----------
11 randy 4 3
12 jim 2 2
13 sam 3 3
14 john 6 7
SQL> create table executive(exno varchar(20), name varchar(25) default 'mahesh',bill int check(bill>5000));
Table created.
SQL> insert into executive values('100','ganesh',5600);
1 row created.
SQL> select * from executive;
EXNO NAME BILL
-------------------- ------------------------- ----------
100 ganesh 5600
SQL> alter table executive add check (bill>5000);
Table altered.
SQL> select * from executive;
EXNO NAME BILL
-------------------- ------------------------- ----------
100 ganesh 5600
SQL> spool off