Professional Documents
Culture Documents
RDBMS Codings
RDBMS Codings
Drda
Manptla ti th Langtu
3) DeL= Dota Contarlcugvage-
1TABLECREATION AND SIMPLE QUERIES
4) DL D»ta u y Langu
=
DDL OUERIES
DMLOUERIES
ILRSCre
FUNCTION
AGGREGATE
2QUERIES
USING
BCODE NUMBER(5
BNAME UARCHAR2(20
UARCHAR2(15)
ANAME NUMBERC5)
PRICE
row created.
SQL
sQL insert into library values(2,'vb.net','ravichandran'.450);
PoW created.
cOUNT CPRICE)
5
750
1200
1950
750
1280
3
SETOPERATIONSS
CODE NUMBER 5
NAME UARCHAR2 (15>
SALARY NUHBERC1O)
$QL insert into staff
values(1,'chandru',30000)D;
rou created.
CODE
bcode fron 1ibrary
2
3
SQL select nane fron gtaff ninus select, bnane fron librarys
NAME
chandru
nalik
steven
$QL select code from staff minus select hcode fron librarys
no rovs selected
SQL select bcode fron lihrary ninus select code fron staff;
BCODE
4
5
VARIQUS JOINS
CREATION WITH
TABLE
varchar2(10),contactnane
number(5),cusname
create table customers(cusid
o number(7)%
nar2(10),address varchar2(10).city varchar2(10),postalcode
SQL> desc customers;
SQL> insert into customers values(1,achu', viji',old st,vellore',623546);
SQL insert into customers values(2, meera', durga', new st,'arcot,623546)%
sQL> insert into customers values(3,durga',sree',koil st,'arni',623359)%
SQL> select*from customers;
SQL> create table orders(orderid number(5),cusid number(5).employecid
number(7),orderdate date,shipperid number(10));
SQL> desc orders;
SQL insert into orders values(2,1,1230,23-mar-95,20);
SQL insert into orders values(7,12,1231,14-feb-14,21);
SQL> insert into orders values(7,12,123 1,14-feb-14,21);
SQL insert into orders values(8,12,12314,20-nov-14,27);
SQL select*from orders;
INNER JOIN
SQL select customers.cusname,orders.orderid from customers inner join orders on
customers.cusid=orders.cusid order by customers.cusname;
where salary>5000);
where client_no>2000)
SQL> select * from client_master2,
1 rou created.
BCODE NUMBER 5
BNAME UARCHAR2269
ANAME HRCHAR2(15)
PRICE NUMBERCS5
$QL select * fron vrs;
rous selected.
1 c balagurusany 300
2 vb.neet ravichandran 450
nichae1 400
3 asp.net
4 sql donhoo 420
balagurus any 380
5 ct+
krithika 350
6 ds
6 r o u s selected.
SQLY delete fron urs yhere hcode-4
1 rou'teletéd.. '
ERROR at line 1:
ORA-80958: invalid DROP option
Uiew dropped.
8.PLSOLPROGRAM FOR TRIGGERS AND ITS TYPE
SQL create table voter(name varchar(10).age number(3),id number(5)-gender varchar(10)
SQL> desc k voter,
SQL> insert into voter values('aaa,25,1 10,female'):
SQL> insert into voter values('bbb'20,111, male')
sQL> insert into voter values(ccc,38,112,female);
SQL> select from voter,
SQL set serveroutput on
SQL> create or replace trigger votl after update or delete on voter for each row
2 declare
3 namel varchar2(10);
4 agel number(3);
5 idl number(5);
6 oper varchar2(25);
7 begin
8 if updating then
9 oper-update operation';
10 else
11 oper-delete operation;
12 end if,
13 idl:-old.id;
14 namel:=old.name;
15 agel:-:old.age
16dbms_output.put_1ine('the"||oper|'was successfully);
17 dbms_ output.put_line(Operation performed on the data');
18 dbms_output.put_line(ID:|id 1||'NAME:"||name l |['AGE:"|age 1);
19 end;
20
Trigger created.
SQL> update voter set name=xxx' where id=110;
theupdate operationwas successfully
Operation performed on the data
ID:110 NAME:aaa AGE:25
SQL> select from voter,
SQL> delete from voter where id=112;
The delete operation was successtully
Operation performed on the data
2.PL/SOLPROGRAM FOR PROCEDURESAND FUNCTIONS
9.1.PROCEDURE
sQL> create table stock(item_code number(10),item_name varchar2(20),
9 else
10 update stock set current_stock=current_stocktic where item_code=ino
11 dbms_output.put_line"'stock updatedsuccessfully);
12 end if,
13 end
14
Procedure created.
SQL begin
2 additem(002,150);
3 end
4
stock updated successfully
PL/SQL procedure successfully completed.
SQI> select from stock;
SQI> execute additem(3,10);
stock updated successfully
PL/ procedure successfully completed.SQI.
9.2.Function
SQL> create table details(phone number(7),user_name varchar2(30),
addr varchar2(30);
Table created.
SQL> desc details;
SQL> insert into details values(2247346, rama', 'newstreet);
1 row created.
5 end;
6
Function created.
5 dbms_output.put_line('address is||ad);
6 end;
address is newstreet
PLSOL procedure successfully completed.