DBMS 5 TO 8
DBMS 5 TO 8
Varchar(255));
Varchar(255));
Create table course(cid int(3) primary key, cname varchar(20),s_id int(3), foreign key
INSERT INTO EMPLOYEE VALUES (1, "SUMIT", "HR"),(2, "JOEL", "IT"),(3, "BISWA",
Natural Join
Outer join
d.DEPT_NAME = e.DEPT_NAME;
d.DEPT_NAME = e.DEPT_NAME;
Procedure Implementation
Table created.
1 row created.
1 row created.
1 row created.
ITEMID
ACTUALPRIC
ORDID PRODID
2 null_price exception;
3 begin
6 raise null_price;
7 else
9 end if;
12 dbms_output.put_line('price is null');
13 end;
14 /
Procedure created.
completed.
ITEMID ACTUAL
PRICE
ORDID PRODID
2 begin
6 dbms_output.put_line('price is null');
7 end if;
8 end;
9/
Procedure created.
2 begin
4 if identity<1000 then
5 b:=100;
6 end if;
7 end;
8/
Procedure created.
SQL> declare
2 a number;
3 b number;
4 begin
5 zzz(101,b);
7 end;
8/
2 begin
3 a:=a+1;
4 end;
5/
Procedure created.
SQL> declare
2 a number:=7;
3 begin
4 itit(a);
6 end;
7/
Function Implementation
Table created.
1 row created.
1 row created.
TNO TFARE
--------- ------------
1001 550
1002 600
Table created.
1 row created.
1 row created.
1 row created.
xxx 11 10000
yyy 12 10500
zzz 13 15500
3 begin
5 return(trainfunction);
6 end;
7/
Function created.
SQL> declare
2 total number;
3 begin
4 total:=aaa (1001);
6 end;
7/
2 fact number:=1;
3 b number;
4 begin
5 b:=a;
6 while b>0
7 loop
8 fact:=fact*b;
9 b:=b-1;
10 end loop;
11 return(fact);
12 end;
13 /
Function created.
SQL> declare
2 a number:=7;
3 f number(10);
4 begin
5 f:=fact(a);
7 end;
8/
DCL COMMANDS
Database changed
+--------------------+
| Database |
+--------------------+
| dcl |
| user1 |
| user2 |
| user3 |
| world |
+--------------------+
varchar(100),age int(255));
+---------+----------+--------+------+
| roll_no | name | branch | age |
+---------+----------+--------+------+
| 10 | anitha | CSE | 14 |
| 14 | bavani | ECE | 15 |
| 17 | yamini | civil | 18 |
| 19 | krishna | mech | 20 |
+---------+----------+--------+------+
+------------------------------------------------------+
+------------------------------------------------------+
+------------------------------------------------------+
+---------------------------------------------------------------+
+---------------------------------------------------------------+
+---------------------------------------------------------------+
+-----------------------------------------------------------------------+
+-----------------------------------------------------------------------+
+-----------------------------------------------------------------------+
2 rows in set (0.00 sec)
+----------------------------------+
+----------------------------------+
+----------------------------------+
+----------------------------------+
+----------------------------------+
+----------------------------------+
+---------------------------------+
+---------------------------------+
+---------------------------------+
TCL COMMANDS
+--------------------+
| Database |
+--------------------+
| account_details |
| clear |
| dbms |
| dcl |
| hello |
| information_schema |
| joinoperation |
| menagerie |
| mysql |
| new_schema |
| performance_schema |
| sakila |
| samp |
| sample |
| sys |
| tcl |
| user1 |
| user2 |
| user3 |
| world |
+--------------------+
Database changed
nagar',94682,35000);
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
mysql> commit;
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
+------------+---------------+-----------------+----------+--------+
To create a simple trigger that does not allow insert update and delete
SQL> create trigger trigg1 before insert or update or delete on employee for each row
2 begin
4 end;
5/
Trigger created.
* ERROR at line 1:
ERROR at line 1:
ERROR at line 1:
Trigger dropped
To create a trigger that raises an user defined error message and does not allow
SQL> create trigger trigg2 before insert or update of salary on employee for each row
2 declare
3 triggsal employee.salary%type;
4 begin
5 select salary into triggsal from employee where eid=12;
8 end if;
9 end;
10 /
Trigger created.
ERROR at line 1:
ERROR at line 1: