Oracle Notes
Oracle Notes
Oracle Notes
97
Ex:
Create table student (SNO number (3), SNAME varchar2(20),
MARKS number(3));
SQL * PLUS: it is a client
environment.
SQL>Conn: it is called connect.
Default username: Scott
Password: tiger
into
into
into
into
student
student
student
student
values(102,kiran,86);
values(103,Ajay,50);
values(104,vijay);//this statement is wrong
values(105,vijay,null);
VALUES
101
102
----------
ENAME
SAL
Mallikarjuna 50000
-------------
SAL*12
600000
-------
DEPTNO
GM
-------
ALL
Page 6 of 110
Syntax:
Update<TABLE_NAME> set <COL_NAME> = <VALUE> where
<CONDITION>;
Ex:
Update student set marks = 30 where sno = 102;
Update emp set sal = 1000 where ename = scott;
Update emp set ename = Arun where eno = 7369;
Update emp set comm = 500 where eno = 7698;
NOTE: when where clunse is not use, all the rows are updated.
Ex:
Update emp set sal = 5000;
Update
Update
Update
Update
Note: AND operator will return the rows when all the conditions
are satisfied.
Select * from emp where SAL >2000 AND JOB = MANAGER AND
deptno = 30;
Select * from emp where DEPTNO = 10 OR DEPTNO = 20;
Select * from emp where SAL >2000 AND SAL < 4000;
Write a query to delete first and last rows?
Ex:
Select * from empno = 7499 OR 7521 OR 7566;
Select * from empno =7499 OR empno = 7521 OR empno =
7566;
Note: query to display the rows who are not managers?
Select * from emp where NOT job = MANAGER;
Select * from emp where NOT deptno = 30;
BETWEEN: between operator is used to display the rows which is
following in the range of values.
Select * from EMP where SAL BETWEEN 2000 AND 3000;
Note: Extreme values are included
Always specify first lower limit first and then higher limit.
*IN OPERATOR:
1. IN operator will be return the rows when the values are matching in
the list.
2. IN operator can be use as a replacement of OR operator.
Ex: Select * from EMP where EMPNO IN(7369,7499,7521);
Select * from EMP where DEPTNO IN(10,20);
Select * from EMP where DEPTNO IN(10,20,30);
*PATTERN MATCHING OPERATOR: They are two pattern matching
operator.
1. Percentage (%)
Page 9 of 110
iii.
iv.
RENAMING A COLUMN:
Syntax: ALTER TABLE <TABLE_NAME> RENAME
COLUMN<OLD_COL_NAME>
TO <NEW_COL_NAME>;
Ex:
ALTER table emp rename column SAL TO WAGES;
Page 11 of 110
Ex:
Create table emp1 AS select * from emp; //total table copy
Create table emp2 AS select * from emp where deptno = 30; //
only deptno = 30
Create table emp3 AS select * from emp where 10; // only deptno
=10 is copy
Create table emp4 AS select empno, ename, wages, deptno from
emp where
deptno = 20; //empno,ename,wages,deptno is coped by emp4
table
Create table emp5 AS select *from emp where 1=2; //This mean
total table copy
Select * from emp where 1 = 1;
Select * from malli from emp;
***Right click
and ok.
properties
/
Run the same query
ED
Open the Buffer command
SET NUM
5
SCOTT is a new user
***Creating a new user:
Connect in the database AS DBA.
*user_name: /AS SYSDBA
*create user: create user malli Identified by malli123; //user and
password created
*giving permissions to the user;
*GRANT CONNECT, RESOURCE TO malli; //Grant Succeeded
*SHOW user To connect the current user.
**FUNCTIONS: Functions will manuplate the data items and gives
the result. They are two types of functions.
1. Group functions or multiple row functions
2. Scalar functions or single row function
1) Group functions or multiple row functions: This functions act on
group of rows.
Page 13 of 110
* from test1;
SNAME MARKS
ARUN 80
ARUN 80
VIJAY
80
Page 15 of 110
SNAME
ARUN
ARUN
VIJAY
LENGTH(SNAME)
4
5
5
ii.
Number functions:
a. ABS: Returns absolute values
Ex: Select ABS(-40) from dual; // 40
Select ABS(40) from dual; //40
b. SQRT: Returns the squawroot values.
Ex: Select SQRT(25) from dual; // 5
Select SQRT(26) from dual; //5.09901951
c. MOD(A,B): Returns the MOD vaues.
Ex: select MOD(10,3) from dual; // 1
d. POWER(A,B):
Ex: Select POWER(2,5) from dual; // 32
e. CEIL:
Ex: Select CEIL(40.9) from dual; //41
Select CEIL(40.2) from dual; //41
Select CEIL(40.5) from dual; //41
f. FLOOR:
Ex: Select FLOOR(40.9) from dual; //40
Select FLOOR(40.2) from dual; //40
Select FLOOR(40.5) from dual; //40
g. TRUNC:(TRUNCATE) Remove the decimal points.
Ex: Select TRUNC(40.9) from dual; // 40
Select TRUNC(40.2) from dual; // 40
Select TRUNC(40.5) from dual; // 40
Page 16 of 110
Select
Select
Select
Select
Select
Conversion functions:
Conversion functions are one data type to another data type
conversion. They are three conversion functions.
TO_CHAR
TO_NUMBER
TO_DATE
Page 19 of 110
***Interview questions***
1. What is SQL?
SQL transfer Structured Query Language are also called as
SEQUEL.
2. List out sub language of SQL?
They are 5 sub languages DDL,DML,DRL/DQL,TCL,DCL .
3. What is different between char and varchar2?
Page 21 of 110
into
into
into
into
student1
student1
student1
student1
values(101,Arun,50);
values(101,Arun,NULL);
values(101,NULL,50);
values(NULL,Arun,50);
Page 23 of 110
into
into
into
into
student2
student2
student2
student2
values(101,Arun,50);
values(101,Arun,NULL);
values(101,NULL,50);
values(NULL,Arun,50);
into
into
into
into
into
student3
student3
student3
student3
student3
values(101,Arun,50);
values(102,Arun,NULL);
values(101,NULL,50);
values(NULL,Arun,50);
values(NULL,Arun,50);
Insert
Insert
Insert
Insert
Insert
into
into
into
into
into
student5
student5
student5
student5
student5
values(101,Arun,50);
values(102,Arun,NULL);
values(101,NULL,50);
values(NULL,Arun,50);
values(NULL,Arun,50);
into
into
into
into
into
into
student9
student9
student9
student9
student9
student9
values(xyz,Arun,40);
values(xyz,Kiran,40);
values(mno,Arun,40);
values(xyz,Kiran,40);
values(NULL,Arun,40);
values(abc,NULL,40);
into
into
into
into
student7
student7
student7
student7
check(city
values(101,ARUN,66,HYDERABAD);
values(101,ARUN,66,DELHI);
values(101,ARUN,66,CHENNAI);
values(101,ARUN,66,NELLORE); //Error
Ex:
Create table Student11(sno number(3),
Sname varchar2(10),
Marks number(3));
Insert into student11 values(101,Arun,60);
Insert into student11 values(102,Arun,80);
Insert into student11 values(103,Arun,90);
ALTER table student11 ADD(Unique(sno));
ALTER table student11 DROP Unique(Sno);
***JOINS: joins are used to retrieve the data from multiple tables.
Types of Joins:
1. EQUI_JOIN
2. NON EQUI_JOIN
3. SELF JOIN
4. OUTER JOIN
4.1
Right outer join
4.2
Left outer join
4.3
Full outer join
1.EQUI_JOIN: when tables are joined basing on a common column it
is called EQUI_JOIN.
Ex: select empno, ename, dname
from emp, dept
where emp.deptno = dept.deptno;
output:
7369
7499
7521
EMPNO
SMITH
ALLEN
WARD
ENAME
DNAME
RESEARCH
SALES
SALES
Note:
We need to mention join conditions in the where clause.
In EQUI_JOINS we along use to equal to operator in join
condition.
Ex:
Selete empno, ename, sal, job, dname, loc
from emp, dept
where emp.deptno = dept.deptno;
Page 32 of 110
City
State
Newyork AP
Dallas
Mh
Ex: Select E.empno, E.ename, E.sal,D.dname,A.state from emp E,
dept D, Areas A
where E.deptno = D.deptno AND D.loc = A.city;
Note: To join n tables we need n-1 conditions.
*NON EQUI JOIN: When we do not use NON EQUI JOIN to operator in
the join condition is NON EQUI JOIN.
Ex:
Select * from SALGRADE;
GRADE
LOSAL
HISAL
1
700
1200
2
1201
1400
3
1401
2000
4
2001
3000
5
3001
9999
Select e.empno, e.ename, e.sal, s.grade from emp e, salgrade s
where e.sal BETWEEN s.losal AND hisal;
EMPNO
7369
7876
7900
ENAME
SMITH
ADAMS
JAMES
GRADE
1
1
2
Ename
FORD
SCOTT
ANALYST
CLERK
Page 34 of 110
JONES
JONES
Job
7900
JAMES
SALESMAN BLAKE
*CARTESIAN PRODUCT:
When tables are joined without any join condition it is called
Cartesian product. In the result we get all possible combination.
Select e.empno, e.ename, e.sal, e.deptno, d.dname, d.loc
from emp e, dept d; //14*4=56 rows are selected
*ANSI JOINS: They are the three types.
1. Inner joins: It is same as Equi join.
Ex:
Select e.empno, e.ename, e.sal, e.deptno, d.dname, d.loc
from emp e INNER JOIN dept d ON(e.deptno = d.deptno);
2.NATURAL JOIN: It is same as Equi join.
Ex:
Select empno, ename, sal, deptno, dname,loc from NATURAL
JOIN dept;
3.CROSS PRODUCT/CROSS JOIN: It is same as Cartesian product.
Ex:
Select e.empno, e.ename, e.sal, e.deptno, d.dname, d.loc
from emp e CROSS JOIN dept d; //14*4 = 56 rows are
displayed.
*DEFAULT:
Ex:
Create table stu1(sno number(3),
Sname varchar2(10),
Marks number(3) default 100,
Doj Date DEFAULT sysdate);
Insert into stu1(sno, sname) values(101,malli);
Insert into stu1 values(102,ARUN,40,11-JAN-09);
Insert into stu1 values (103,KIRAN,NULL,12-FEB-10);
SNO SNAME MARKS
DOJ
101
malli
100
26-JUN-12
102
ARUN 40
11-JAN-09
103
KIRAN
12-FEB-10
Page 35 of 110
ename
james
adams
adams
sal
950
1400
2000
deptno
30
20
10
dname
sales
clerk
sales
anaylist
loc
chicago
newyork
india
ap
*SET OPERATORS: Set operators are used to retrieve the data from
multiple tables.
They are different types.
1. UNION:
Select * form student10;
Sno
sname
marks
101
Arun
40
102
Arun
50
103
Arun
69
Select * from student20;
Sno
sname
marks
103
Arun
90
104
Arun
60
Union Syntax: (no duplicates)
Select sno from student 10
Union
104
Select sno from student 20;
2. UNION ALL:
Union All Syntax: (All rows)
Select sno from student 10
Union All
// o/p sno: 101 102 103
103 104
Select sno from student 20;
3. INSERT SECT:
Insert Sect Syntax: (common rows)
Select sno from student 10
Insert Sect
Select sno from student 20;
4. MINUS:
Page 37 of 110
// valid
INTERVIES QUESTIONS
1. What is need for Integrity constraint?
Constrains are rules which are applied on tables.
2. List out types of constraints?
They are 5 types NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN
KEY, and CHECK.
3. In how many level constraints can be created?
Those are two levels i.e. column level and table level.
4. Which can constraint can be created?
The constraint created not null.
5. Dose not null constraints accept duplicate values?
Yes
6. Which constraint is used to unique for every row in the table?
Primary key
7. What is composite primary key?
When primary key is applied on multiple columns it is called
composite primary key. Composite primary key can be applied
only at table level.
Page 38 of 110
*SAVE POINT: Save points are logical marking given for series of
transaction.
Instead of complete rollback we can rollback to a save point.
Syntax: SAVEPOINT<SAVEPOINT_NAME>;
Ex:
Create table student3(sno number(3),
Name varchar2(10),
Marks number(3));
Page 41 of 110
Insert
Insert
Insert
Insert
Insert
into
into
into
into
into
student3
student3
student3
student3
student3
values(300,Arun,69);
values(301,Kiran,69);
values(302,Naga,69);
values(303,Arun,69);
values(304,Kiran,69);
SAVEPOINT A;
Insert into student3 values(305,Naga,69);
Insert into student3 values(306,Kiran,69);
Insert into student3 values(307,Naga,69);
Select * from student3;
ROLLBACK;
Select * from student3;
SAVEPOINT Q;
Insert into student4 values(304,Naga,69);
Insert into student4 values(305,Naga,69);
Select * from student4;
ROLLBACK;
Select * from student4;
// 6 rows
//0 rows
Page 42 of 110
Note: All the save points are lost when the DB is permanent.
***DCL (Data Control Language):
They are two Data Control Languages.
1. GRANT
2. REVOKE
Schema: Schema is a memory location which is associated to a user.
It is collection of objects.
Privilege: privileges are permissions (rights given to a user)
They are two types of privileges.
1. System Privileges
2. Object Privileges
*System Privileges: These privileges are given by DBA to user.
*Object Privileges: These Privileges are given by one user to
another user.
*GRANT: Grant command is used to Grant the privileges to the user.
Syntax:
GRANT <PRIVILEGE_NAME1>,<PRIVILEGE_NAME2> TO
<USER_NAME>;
Ex:
Create user kiran IDENTIFIED by kiran123;
Create user naga IDENTIFIED by naga123;
DBA> GRANT CONNECT, RESOURCE to kiran;
*Object Privileges: These privileges are given by one user to
another user.
KIRAN
DBA
AJAY
Page 43 of 110
101
102
103
Arun
Anil
Kiran
30
40
50
Select
SNO
101
105
rows merge
SNAME MARKS
James 90
Anil
40
Kiran
50
Smith 50
and
sal
Page 48 of 110
Select * from emp where(job,sal) IN(select job, sal from emp where
deptno = 30);
o/p:
Job
sal
salesman
manager
salesman
1600
1250
2850
Note: In the o/p we get the rows when both the values are matching.
Delete some valuesu:
Select * from student;
Select min(rowid) from student group by sno;
Select max(rowid) from student group by sno;
Delete from student
where rowid not
IN(select min(rowid) from
student group by sno);
*write a query to display the row from emp table who is having the
highest salary?
Select * from emp where sal = (select max(sal) from emp);
*write a query to display all the rows who are having salary grater
than AVG salary of emp table?
Select * from emp where sal >(select AVG(sal) from emp);
*write a query to display all deptno AVG salary?
Select deptno, AVG(sal) from emp group by deptno;
*Co-RELATED SUBQUERY:
When subquery is executed in relation to parent query, it is called corelated subquery.
*write a query to display all the rows who are having salary grater
than AVG salary his department?
Select AVG(sal) from emp;
Select * from emp where sal > (select AVG(sal) from emp group by
deptno); //invalid
Page 49 of 110
Select * from emp where sal > (select AVG(sal) from emp where
deptno = 10);
***Select * from emp e
where sal > (select AVG(sal) from emp where deptno =
e.deptno);
o/p:
sal
1600
2975
2850
3000
5000
3000
deptno
30
20
30
20
10
20
subcaluse
scalar
inline
yes
INTERVIEW QUESTIONS
1. What are pseudo columns?
It is rownum is a pseudo column which starts with one and
increment by 1.
2. Write a query to display first n rows from the table?
Select rownum, empno, ename, sal, deptno from emp;
3. What are different between rownum and rowid?
Rownum
Rowid
Rownum values starts with 1
Rowids are hexadecimal
values.
and increment by one.
Rownum values are temporary.
Rowid values are
permanent.
Rownum values are generated
The Rowid values are
generated when
when query is executed.
row is created or inserted.
Page 51 of 110
Ename
Smith
Allen
-----------
Sal
800
1600
-----------
Tables which are used for creating the view are called as above
tables.
Select * from TAB; will gives list of all the tables and view which are
the data base tables.
Ex:
Create view emp_V10 AS select empno, ename, sal, deptno, from
emp
where deptno =
10;
Create view emp_V10 AS select empno, ename, sal, deptno, from
emp
where deptno =
20;
Create view emp_V10 AS select empno, ename, sal, deptno, from
emp
where deptno =
30;
Select * from V10;
Select * from V20;
Select * from V30;
We can perform DML operations on simple views.
Any DML operation performed on simple view will be reflected on
base table.
To see the structure of the table.
Page 53 of 110
Ex:
DESC V1
Name Null
Empno
Ename
Sal
Type
Notnull
number(4)
varchar2(10)
number(7,2)
Text
select empno, ename, sal, deptno
from emp where deptno = 30;
In user_view from the database we get list of all the view and
corresponding select statement used for the view.
Select view_name, Text from user_views;
*Complex view:
When a view is created using multiple base tables it is called Complex
view.
Ex:
Create view Test_v7
As select e.empno, e.ename, e.sal, e.deptno,
d.dname, d.loc from emp e, dept d where e.deptno =
d.deptno;
insert into Test_v7 values(7878,ravi,9000,40,HR,HYD);
msg: DML operations are not allowed in complex views.
Create view Test_v8
Page 54 of 110
// Error
// valid
// error (invalid)
//performance fast
//performance fast two tables
Syntax:
Create MATERIALIZED view <VIEW_NAME> AS <select STMT>;
Ex:
Page 56 of 110
of ROWIDs
SAL
800
950
1100
1250
1600
5000
1. NEXTVAL
2. CURRVAL
*NEXTVAL: Nextval is used to generate a number.
*CURRVAL: Currval is used to know the latest number generated.
Create sequence SE5 start with 101 increment by 1;
Insert into student7 values(SE5.NEXTVAL,Arun,60);
Insert into student7 values(SE5.NEXTVAL,Amit61);
Sequence is a sharable object.
When sequence is shared we get gaps in numbers.
Example of CURRVAL: To know the latest value generated.
Ex:
Select SE5.CURRVAL from dual;
Sequence with cache option will help in generating the numbers
faster.
Ex:
Create sequence SE6 start with 1000 increment by 1 maxvalue
10000 cycle cache 40;
Cache option will help in improving the performance of sequence.
*Synonym: it is an alternate name given to an object.
1. Table
2. View
3. Index
4. Sequences
5. Synonyms
Synonym Objects of PL/SQL:
1. PROCEDURE
2. FUNCTION
3. PACKAGE
4. TRIGGER
Normalization: Normalization is process of removing redundancy
and improving accurency of the database. Normalization can be
achieved by using normal forms.
*1st Normal form (1NF): A database is in 1NF if it satisfies following
rules.
Rule1: Each cell should have one value.
Rule2: Table should have primary key.
Ex: Author ID
Author Name
Book Name
PRIMARY
KEY
Book Cost
Author ID
A101
IVAN
SQL
200/Author Name
A101
IVAN
PLSQL
250/-
Price
Page 61 of 110
Partial dependency
In the above table S Name (non key attribute) is depending on
supplier ID (part of primary key). Hence these exists partial
dependency. We can eliminate partial dependency by dividing the
table into two different tables. The following tables are satisfying 2NF
rules.
Primary key
Primary key
Part ID Supplier ID
Price
65
2
59
73
2
60
Supplier ID S Name
Address
2
TATA
Bangalore1
BIRLA
TOYOTA
PARK
MISTUBUSHI
LOS
Toyota
ManfName
ManfAddress
Toyota
Park
Avenue
Inter view Questions:
Page 62 of 110
1. What is view?
A view is a logical representation of data from one or more then
one table.
2. List of different between single views and complex views?
3. In which cases a view is called complex view?
When a view is created using multiple base tables it is
called complex view.
4. How can we restrict DML operations on simple views?
We can perform DML operations on simple views. Any DML
operation performance on simple view will be reflected on base
table.
5. What is with check option view?
These views will allow DML operation only when where condition
is satisfied.
6. Do you think view contains data?
View does not contain any data.
View does not consume memory location.
When we write select statement on view, we get the data from
the table.
7. What is a data dictionary table used to see the list of view?
8. What is a materialized view?
Materialized views will help improving the performance of select
statement on view.
9. What is the advantage of index?
Index is an object which is used to improve the performance of
select statements.
10. What is the disadvantage of index?
Index will consume memory.
The performance of DML command will be decreased.
11. What is unique index?
If the indexed column contains unique value it is called unique
index.
A unique index is automatically created. When we create a table
with primary key constraint or unique constraint.
Page 63 of 110
All views that are theoretically update must be update table by the
system.
Rule 7: High-level insert, update, and delete:
This rule states that insert, update and delete operations should be
supported for any retrievable set rather then just for a single row in a
single table.
Rule 8: Physical data independence:
Changes to the physical level (How the data is stored, whether in
arrays or linked lists etc.) must not require a change on application
based on the structure.
Rule 9: Logical data independence:
Changes to the logical level (tables, columns, rows, and so on) must
not require a change to an application based on the structure.
Rule 10: Integrity independence:
This rule says that, it must be possible to change such constrains as
and when appropriate without unnecessarily a selecting existing
application.
Rule 11: Distribution independences:
The distribution of portions of the database to various locations
should be invisible to users of the database.
Rule 12: The non subversion rule:
If the system provides a low-level (record-at-a-time) interface, then
that interface cannot the used to subvert (degrade) the system.
*Script: A script is a file which is collection of commands same with
extension .SQL
To run the script @D:\malli\FIRST.SQL
Page 65 of 110
***PL/SQL***
It is extension of SQL the following or advantages of PL/SQL.
1. We can use programming features like if statement loops etc.
2. PL/SQL helps in reducing network traffic.
3. We can have user defined error massages by using concept of
exception handling.
4. We can perform related actions by using concept of Triggers.
5. We can save the source code permanently for repeated
execution.
PL/SQL Block:
A PL/SQL programs called as PL/SQL block.
Page 66 of 110
PL/SQL Block:
DECLARE
------------------------------------------------- --DECLARE SECTION --OPTIONAL
------------------------BEGIN
------------------------------------------------- --EXECUTABLE SECTION --MANDATORY
------------------------EXCEPTION
------------------------------------------------- --EXCEPTION SECTION --OPTIONAL
------------------------END;
/
*Declare: This section is used to declare local variables, cursors,
Exceptions and etc. This section is optional.
*Executable Section: This section contains lines of code which is
used to complete table. It is mandatory.
*Exception Section: This section contains lines of code which will be
executed only when exception is raised. This section is optional.
END;
/
o/p: Hello world
PL/SQL procedure successfully completed.
Note: To get the output of the program server output environment
variable should be on.
Command: SET SERVEROUTPUT ON
DBMS_OUTPUT is name of the PACKAGE
.PUT_LINE is name of the PROCEDURE
/ Slash is used to submit the program in DBS.
*Write PL/SQL block which will calculate some of two numbers and
display the output?
DECLARE
A number(2);
B number(2);
C number(3);
BEGIN
A := 10;
B := 20;
C := A + B;
DBMS_OUTPUT.PUT_LINE(C);
DBMS_OUTPUT.PUT_LINE( sum of two numbers || C);
END;
/
o/p: 30
o/p: sum of two numbers 30
PL/SQL procedure successfully completed.
--is a Single line comment.
/*
*/ ----Multi-Line comment
Ex:
Initialization in declare section
A number(2) := 50;
B number(2) := 25;
Page 68 of 110
*Write a PL/SQL block which accepts two numbers from the user and
display the sum?
DECLARE
A number(2);
B number(2);
C number(3);
BEGIN
A := &A; or A := &malli;
B := &B; or B := &iNetSlov
C := A + B;
DBMS_OUTPUT.PUT_LINE( sum of the two numbers || C);
END;
/
To modify the data
Begin
Merge----------------Insert-----------------Update---------------Commit--------------Select---------------- // not execute
END;
/
DCL--------NO
DDL--------NO
DML------YES
DRL--------NO
TCL--------YES
*Write a PL/SQL block which accepts employee number and
increment is salary by 1000?
DECLARE
A number(4);
A := &Empno;
Update emp set sal = sal + 1000 where Empno = A;
END;
Page 69 of 110
/
*Write a PL/SQL block which empno and delete that row from the emp
table?
DECLARE
A number(4);
BEGIN
A := &Empno;
Delete from emp where Empno = A;
END;
/
*Control statement: If Then Else
Declare
A number := 5;
Begin
DBMS_OUTPUT.PUT_LINE( welcome );
If A > 10 Then
DBMS_OUTPUT.PUT_LINE( HELLO1 );
Else
DBMS_OUTPUT.PUT_LINE( HELLO2 );
END If;
DBMS_OUTPUT.PUT_LINE( THANK YOU );
END;
/
*LOOPS: There are three types
1. Simple loop
2. While loop
3. for loop
1. Simple:
Declare
A number(2) := 1;
Begin
DBMS_OUTPUT.PUT_LINE( welcome );
LOOP
DBMS_OUTPUT.PUT_LINE( HELLO1 );
DBMS_OUTPUT.PUT_LINE( HELLO2 );
Exit when A = 4;
Page 70 of 110
A := A + 1;
END LOOP;
DBMS_OUTPUT.PUT_LINE( THANK YOU );
END;
/
2. While:
Declare
A number(2) :=1;
Begin
DBMS_OUTPUT.PUT_LINE(
While A <=4 loop
DBMS_OUTPUT.PUT_LINE(
DBMS_OUTPUT.PUT_LINE(
A := A + 1;
END LOOP;
DBMS_OUTPUT.PUT_LINE(
END;
/
3. FOR LOOP:
Declare
A number;
Begin
DBMS_OUTPUT.PUT_LINE(
FOR A IN 1 .. 4 LOOP
DBMS_OUTPUT.PUT_LINE(
DBMS_OUTPUT.PUT_LINE(
END LOOP;
DBMS_OUTPUT.PUT_LINE(
END;
/
WELCOME );
HELLO1 );
HELLO2 );
THANK YOU );
WELCOME );
HELLO1 );
HELLO2 );
THANK YOU );
END;
/
*write a program accepts deptno and display deptname and location?
Declare
L_Deptno number(2);
L_DName varchar2(15);
L_Loc varchar2(10);
Begin
L_Deptno := &Deptno;
Select DName, Loc into L_DName, L_Loc from dept where Deptno =
L_Deptno;
DBMS_OUTPUT.PUT_LINE( L-DName );
DBMS_OUTPUT.PUT_LINE( L_Loc);
END;
/
*Using % type attribute:
Percentage type attribute is used to declare local variable with
respect to column of a table.
Syntax: <VAR_NAME><TABLE_NAME>.<COL_NAME> % TYPE;
Ex:
L_Dname Dept.Dname%TYPE;
*Write a program which accepts empno to display ename, job and
salary?
Declare
L_empno emp.empno % type;
L_ename emp.ename % type;
L_job emp.job % type;
L_salary emp.salary % type;
Begin
L_empno := &empno;
Select ename, job, salary into L_ename, L_job, L_salary from emp
where empno = L_empno;
DBMS_OUTPUT.PUT_LINE( L_ename );
DBMS_OUTPUT.PUT_LINE( L_job );
DBMS_OUTPUT.PUT_LINE( L_salary );
(or)
DBMS_OUTPUT.PUT_LINE( L_ename|| L_job||||L_salary);
Page 72 of 110
END;
/
Note:
When a select statement does not return any row program will
terminate abnormally.
When select statement returns more then one row, program will
terminate abnormally.
*Percentage (%) Row type attributes:
This attribute to declare a local variable which can store complete
Row of a table.
Syn:
<VARIABLE_NAME> <TABLE_NAME> % ROW TYPE;
Ex:
A EMP%ROWTYPE;
We cannot directly display a Row type variable.
We can access one value in Row type variable by using.
<VARIABLE_NAME>.<COL_NAME>
Ex:
Declare
A EMP%ROWTYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE( WELCOME );
Select * INTO A from emp where empno = 7782;
DBMS_OUTPUT.PUT_LINE(A.sal||A.job||A.Hiredate);
DBMS_OUTPUT.PUT_LINE( THANK YOU );
END;
/
*EXCEPTIONS:
Runtime Errors are called as Exceptions. They are three types of
Exceptions.
1. ORACLE Predefined Exception
2. ORACLE Non Predefined Exception
3. USER Defined Exception
*Oracle Predefined Exception:
These Exceptions will have Exception name and Exception number.
Examples of predefined Exceptions are:
Page 73 of 110
1.
2.
3.
4.
5.
NO_DATA_FOUND
TOO_MANY_ROWS
ZERO_DIVIDE
VALUE_ERROR
DUP_VAL_ON_INDEX
Declare
A Number;
Begin
A := 5/0;
Exception
when ZERO_DIVIDE then
DBMS_OUTPUT.PUT_LINE( DO NOT DIVIDE BY 0 );
END;
/
Note:
This Exception is raised when we try to divided by zero.
*VALUE_ERROR: This Exception is raised when there is miss match
with the value and data type of local variable or size of local
variables.
Ex 1:
Declare
L_sal emp.sal%type;
Begin
DBMS_OUTPUT.PUT_LINE( WELCOME );
Select ename INTO L_sal from emp where empno = 7521;
DBMS_OUTPUT.PUT_LINE(L_sal);
DBMS_OUTPUT.PUT_LINE( THANK YOU );
EXCEPTION
when VALUE_ERROR then
DBMS_OUTPUT.PUT_LINE( please check the local variables);
END;
/
Ex 2:
Declare
A number(3);
Begin
A := 1234;
Exception
when VALUE_ERROR then
DBMS_OUTPUT.PUT_LINE( PLEASE CHECK THE LOCAL VARIABLES );
END;
/
Page 75 of 110
NO DATA FOUND
EXACT FETCHED
THEN ONE ROW
3.ZERO_DIVIDE
ORA-1476
DIVISON IS EQUAL TO ZERO
4.VALUE_ERROR
ORA-6502
ERROR
5.DUP_VAL_ON_INDEX
ORA-0001
CONSTRAINT VIOLATED
NUMRIC OR VALUE
UNIQUE
*WHEN OTHERS:
When others are a universal Exception angular this can catch all the
Exceptions.
Declare
L_sal number(4);
A number;
Begin
DBMS_OUTPUT.PUT_LINE( Welcome );
Select sal INTO L_SAL from emp where deptno = &deptno;
Page 76 of 110
A number := 10;
Begin
DBMS_OUTPUT.PUT_LINE(HELLO1);
Declare
B number := 20;
Begin
DBMS_OUTPUT.PUT_LINE(HELLO2);
DBMS_OUTPUT.PUT_LINE(B);
DBMS_OUTPUT.PUT_LINE(A);
END;
DBMS_OUTPUT.PUT_LINE(HELLO3);
DBMS_OUTPUT.PUT_LINE(B); --ERROR
END;
/
Note: outer block variables can be accessed in nested block nested
block variables can not be accessed in outer block.
*EXCEPTION PROPAGATION:
Begin
DBMS_OUTPUT.PUT_LINE(HELLO1);
L_SAL EMP.SAL%TYPE;
Begin
DBMS_OUTPUT.PUT_LINE(HELLO2);
Select sal INTO L_SAL from emp where empno = 1111;
DBMS_OUTPUT.PUT_LINE(HELLO3);
END;
DBMS_OUTPUT.PUT_LINE(HELLO4);
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE(HELLO5);
END;
/
*ORALE NON PREDEFINED EXCEPTIONS:
These Exceptions will have only Exception number. But does not have
Exception name.
Steps to handle non predefined exceptions.
Syntax:
Step1: Declare the Exception
<EXCEPTION_NAME> EXCEPTION;
Page 78 of 110
MY_EX1 EXCEPTION;
--Step1
L_SAL EMP.SAL%TYPE;
Begin
DBMS_OUTPUT.PUT_LINE(welcome);
Select SAL INTO L_SAL from emp where empno = &empno;
IF L_SAL > 2000 THEN
RAISE MY_EX1;
--Step2
ENDIF;
DBMS_OUTPUT.PUT_LINE(The sal is ||L_sal);
DBMS_OUTPUT.PUT_LINE(Thank you);
EXCEPTION
WHEN MY_EX1 THEN
--Step3
DBMS_OUTPUT.PUT_LINE(Sal is two high);
END;
/
Note: When others should be the last handler of the exception
section other wise we get a compiler ERROR.
*RAISE_APPLICATION_ERROR: RAISE_APPLICATION_ERROR is a
procedure which is used to throw one error number and error
message to the calling environment.
It internally performance rolls back.
ERROR number should be range of -20000 to -20999. ERROR
message should be displayed less then or equal to 512 characters.
Declare
L_sal emp.sal%TYPE;
Begin
DBMS_OUTPUT.PUT_LINE(Welcome);
Insert INTO dept values (08,arun,70);
Select sal INTO L_sal from emp where empno = 7698;
IF L_sal > 2000 THEN
RAISE_APPLICATION_ERROR(-20150, SAL IS TOO HIGH);
END IF;
DBMS_OUTPUT.PUT_LINE(THE SAL IS||L_SAL);
END;
/
Page 80 of 110
SQL%ISOPEN
SQL%FOUND
SQL%NOTFOUND
SQL%ROWCOUNT
Begin
Update emp set sal = 2000 where deptno =30;
DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT||ROWS UPDATED);
END;
/
*SQL%ISOPEN
Begin
Update emp set sal = 1000 where empno = 7654;
IF SQL%ISOPEN THEN
DBMS_OUTPUT.PUT_LINE(CURSOR IS OPEN);
ELSE
DBMS_OUTPUT.PUT_LINE(CURSOR IS CLOSED);
END IF;
END;
/
Note: By the time we check whether cursor is open or not it is
already closed by the oracle engine. Hence it is always returns false.
*write a PL/SQL block which accepts deptno and display all the
employee names of the department?
Declare
L_ename emp.ename%TYPE;
Begin
Select ename into L_ename from emp where deptno = &deptno;
DBMS_OUTPUT.PUT_LINE(L_ename);
--ERROR
END;
/
**EXPLICIT CURSORS: All the activities related to cursor like.
1. Opening the cursor
2. Processing the cursor
3. Closing the cursor
Act should be done by the developer. Hence this cursor is called
explicit cursors.
We should use explicit cursors to run a select statement. Which
returns more then one row?
Page 82 of 110
DATABASE
ENAME
C1
Loop
Fetch c1 into L_dname, L_loc;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(L_dname||L_loc);
END loop;
Close c1;
END;
/
*write a program to display employee names, job, salary who are
working in a department number 30?
Declare
CURSOR c1
IS select ename,job,salary from emp where deptno = 30;
A c1%ROWTYPE;
Begin
OPEN c1;
LOOP
FETCH c1 INTO A;
EXIT WHEN c1 %NOTFOUND
DBMS_OUTPUT.PUT_LINE(A.ename||||A.job||||A.salary);
END LOOP;
END;
/
*CURSOR FOR LOOPS:
It is a short cut way of writing an explicit cursor program. When we
use cursor for loop following steps are not required.
1. Opening the cursor not required.
2. Closing the cursor not required.
3. Fetch statement not required.
4. Exit when condition not required.
5. Declaring local variable not required.
Declare
CURSOR c1
IS select ename, job, salary from emp where deptno = 30;
Begin
FOR A IN c1 LOOP
Page 85 of 110
DBMS_OUTPUT.PUT_LINE(A.ename||||A.job||||A.salary);
END LOOP;
END;
/
*Write a program to display the entire employee numbers their
names and location?
Declare
CURSOR c1
IS select E.empno, E.ename, D.loc from emp E, Dept D where
E.Deptno = D.Deptno;
Begin
FOR A IN c1 LOOP
DBMS_OUTPUT.PUT_LINE(A.empno||||A.ename||||A.loc);
END LOOP;
END;
/
SNO
101
102
103
104
105
SNAME SUB1
ARUN
60
VARUN 65
SREENU 60
AMIT
60
VEERA
40
SUB2
70
77
91
70
50
SUB3
80
80
80
88
60
*Write a program it will calculate AVG marks from the entire student
table?
Declare
CURSOR c1
IS select * from student;
L_AVG number(5.2);
Begin
FOR A IN c1 LOOP
L_AVG := (A.sub1 + A.sub2 + A.sub3)/3;
DBMS_OUTPUT.PUT_LINE(AVERAGE OF ||A.sno||IS||L_AVG);
END LOOP;
END;
/
*Using%ISOPEN attribute:
Page 86 of 110
Declare
Cursor c1
IS select empno, ename from emp where deptno = 20;
L_empno emp.empno%TYPE;
L_ename emp.ename%TYPE;
Begin
open c1;
IF c1%ISOPEN then
DBMS_OUTPUT.PUT_LINE(cursor is open);
Else
DBMS_OUTPUT.PUT_LINE(cursor is closed);
END IF;
END;
/
*Using%ROWCOUNT attribute: This attribute is used to fetch
limited number of rows from the local variables.
Ex:
Declare
Cursor c1
IS select empno, ename from emp where deptno = 20;
L_empno emp.empno%TYPE;
L_ename emp.ename%TYPE;
Begin
open c1;
Loop
FETCH c1 INTO L_empno, L_ename;
Exit when c1%ROWCOUNT = 3;
DBMS_OUTPUT.PUT_LINE(L_empno||..||L_ename);
END Loop;
close(1);
END;
/
*Parameterized cursor: A cursor which accepts a parameter from
the user is called as parameterized cursor. Active dataset changes
dynamically basing on the value passed to the cursor.
Ex:
Declare
Cursor c1(A number)
Page 87 of 110
1. InParameter:
InParameters are used to accept values from the user.
Ex: create a procedure which accepts two numbers and display the
num?
*Create or replace procedure ADD_NUM(A IN number, B IN number)
IS
C number;
Begin
C := A + B;
DBMS_OUTPUT.PUT_LINE(The sum is||C);
END;
/
*create a procedure which accepts employee number and increment
salary by 1000?
Create or replace procedure INC_SAL (A IN number)
IS
Begin
Update emp set sal = sal + 1000 where empno = A;
END;
/
*create a procedure which accepts employee number and display
salary?
Create or replace procedure display_sal (L_empno IN emp.empno
%TYPE)
IS
L_sal emp.sal%TYPE;
Begin
Select sal INTO L_sal from emp where empno = L_empno;
DBMS_OUTPUT.PUT_LINE(The sal is .||L_sal);
END;
/
*create a procedure which accepts deptno and display the name and
location?
Create or replace procedure display_details(L_deptno IN dept.deptno
%TYPE)
IS
Page 89 of 110
L_Dname dept.Dname%TYPE;
L_loc dept.loc%TYPE;
Begin
Select Dname, loc INTO L_Dname, L_loc from dept where deptno =
L_Deptno;
DBMS_OUTPUT.PUT_LINE(L_Dname||.||L_loc);
Exception
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE(IN value NO);
END;
/
Query to see all the list of procedures:
Select object_NAME from user_objects
PROCEDURE;
where
object_TYPE
Begin
P1;
ADD_NUM(20,15);
DISPLAY_SQUARE(1);
END;
/
We can remove the procedure by using drop command.
Ex: drop procedure p1;
We can call a procedure using another procedure there exist
depending between the procedures.
Ex:
Create or replace procedure test11
IS
Begin
DBMS_OUTPUT.PUT_LINE(This is from test11);
END;
/
Create or replace procedure sample11
IS
Begin
DBMS_OUTPUT.PUT_LINE(This is from sample11);
END;
/
Note:
When we drop test11 procedure, sample11 procedure will become
invalid.
**Out parameters: out parameters are used to return the value to
the user.
Ex:
Create a procedure which accepts two numbers and return the sum?
Create or replace procedure ret_sum
(A IN number,B IN number, C
OUT number)
IS
Begin
C := A + B;
END;
/
Page 91 of 110
Note:
The scope of the bind variable is with respect to one session.
Once the environment is closed all the bind variables are lost.
*Functions:
A function is a named PL/SQL block which must and should return a
value.
Syntax: create or replace function<FUNCTION_NAME>(VAR1
datatype, var2 datatype,.,varn datatype);
Return datatype
IS
Begin
------------------END;
/
Ex: Create a function which accepts two numbers and returns the
sum?
Create or replace function ADD_NUM_FUN(A number, B number)
Return number
IS
C number;
Begin
C := A + B;
Return C;
END;
/
Output: function created
Calling:
Declare
N number;
Begin
N := ADD_NUM_FUN(10,20);
DBMS_OUTPUT.PUT_LINE(N);
END;
/
Page 93 of 110
DBMS_OUTPUT.PUT_LINE(emp_rec.ename);
END LOOP;
END;
Function cal_tax(L_sal emp.sal%TYPE)
Return number
IS
Begin
Return(L_sal*10/100);
END;
END test_PKG1;
/
To invoke a sub program which is inside the package, we need to
mention package name subprogram name.
Ex: Exec test_PKG1.p1
Select test_PKG1.cal_tax(2500) from dual;
Note:
Packages can not be parameterized.
Packages can not be nested.
Packages help in modularization.
Packages help in overloading subprograms.
Example of overloading sub programs:
Create or replace package test_pkg2
IS
Procedure p1(A number);
Procedure p1(A number, B number);
END test_pkg2;
/
PKB:
Create or replace package body test_pkg2
IS
Procedure p1(A number)
IS
B number;
Begin
B := A * A;
DBMS_OUTPUT.PUT_LINE(The square is ||B);
END;
Page 96 of 110
Ex:
create or replace trigger trg1
after insert on dept
begin
DBMS_OUTPUT.PUT_LINE(hello);
END;
/
Trigger created
SQL> insert into dept values(65,Admin,HYD);
Trigger can be created on multiple events
Ex:
Create or replace trigger trg1
After insert or update or delete on dept
Begin
If inserting then
DBMS_OUTPUT.PUT_LINE(thank you for inserting);
ElsIf updating then
DBMS_OUTPUT.PUT_LINE(thank you for updating);
Else
DBMS_OUTPUT.PUT_LINE(thank you for deleting);
End If;
END;
/
SQL> insert into dept values(65,arun,hyd);
Thank you for inserting
SQL> deleting from dept where deptno = 65;
Thank you for deleting
*Triggers are divided into two types
1. Statement level trigger
2. Row level trigger
*Statement level trigger:
These triggers are executed only once irrespective of number of rows
affected by the event. By default every trigger is a statement level.
*Row level trigger:
Page 98 of 110
These triggers are executed for every row which is affected by the
event (multiple numbers of times). We can create a row level trigger
by using FOR EACH ROW clause.
Ex:
Create or replace trigger trg2
After update on emp for each row
Begin
DBMS_OUTPUT.PUT_LINE(thank you for updating);
END;
/
Trigger updated
SQL> update emp set sal = 2000 where deptno = 30;
Output:
Thank you for updating
Thank you for updating
Thank you for updating
Thank you for updating
Thank you for updating
Thank you for updating
6 rows updated
Triggers are used to enforce business rules.
We can enforce business rules by using :OLD and :NEW qualifiers.
*Query to see list of all the triggers:
Select object_Name from user_objects where object_TYPE = Trigger;
OR
Select Trigger_Name from user_Trigger;
*To see the source code of a trigger:
Select text from user_source where name = trg2;
*To drop a trigger:
Syntax: drop trigger <trigger_name>.
Ex: drop trigger trg2;
*Using: new qualifier:
*Create a trigger which will allow insert command only when salary is
less than 5000. Trigger should reject the insert command by providing
a meaningful message. If SAL > 5000?
Page 99 of 110
Create or replace trigger TRG5 before insert on emp for each row
Begin
If :new.sal>5000 then
Raise_application_error(-20150,sal cannot be more than 5000);
END IF;
END;
/
Ex:
insert
into
emp(empno,
ename,
sal,
values(444,BBB,7500,10);
Output: ERROR ORA-20150 :sal cannot be more than 5000
deptno)
Insert
into
emp(empno,
values(111,AAA,2500,10);
Output: 1 row created
deptno)
ename,
sal,
*create a trigger which will accept insert command only for deptno
10?
Create or replace trigger trg3 before insert on emp for each row
Begin
IF :new.deptno<>10 then
Raise_application_error(-20150,deptno should be only 10);
END IF;
END;
/
*Using :old qualifier:
*A trigger should restrict delete operation on president?
Create or replace trigger trg7 before delete on emp for each row
Begin
IF :old.JOB = president then
Raise_Application_Error(-20150,cannot delete president);
END IF;
END;
/
Delete from emp where empno = 7839;
Error: ORA -20152, cannot delete president
Delete from emp where empno = 7499;
--- valid
Page 100 of 110
*Abstract datatypes:
Abstract data types are consists of one or more subtypes. Rather than
being constrained to the standard oracle data types of number, date
and varchar2 data types can more accurately describe your data.
Ex:
SQL>create type address_ty5 as object
(street varchar(20),
city varchar2(10),
state char(10),
pin number);
/
Type created
SQL> create type person_ty5 as object
(name varchar2(20),
Address address_ty5);
/
Type created
SQL> create table customer5
(customer_ID number(3),
Person person_ty5);
SQL> insert into customer5 values
(1,person_ty5(hari,address_ty5(#102
lokhanadala,mumbai,MH,10101)));
SQL> select customer_ID, c.person.name from customer c;
*Nested table:
Nested table is a collection of rows, represented as a column with in
the main table.
For each record with in the main table, the nested table may contain
multiple rows. In one sense, its a way of storing a one-to-many
relationship with in one table.
SQL> create or replace type emp_ty5 as object
(desg varchar2(20),
dname varchar2(20),
doj date);
Page 102 of 110
/
Type created
SQL> created type emp_nt5 as table of emp_ty5;
/
Table created
SQL> created table emp data5
(ename varchar2(20),
details emp_nt5)
nested table details store as emp_nt_tab5);
Table created
SQL> set describe depth2
SQL> desc empdata5
Name
Ename
Details
Desg
Dname
Doj
Type
Varchar2(20);
Emp_nt
Varchar2(20)
Varchar2(20)
Date
tables
*Execute immediate:
One can call DDL statement like create, drop, truncate and etc from
PL/SQL by using the Execute immediate statement.
Ex:
Begin
Execute immediate drop table dept;
END;
/
Begin
Execute immediate Truncate table emp;
END;
/
*BULK COLLECT:
Bulk collect feature helps in improving the performance of explicit
cursor programs.
Fetch statement can fetch all the rows from the cursor to the
programs local variable at once thus helps in improving the
performance.
Ex:
Declare
Type string_array is varray(20) of varchar2(20);
Page 104 of 110
L_ename string_array;
Cursor c1
Is select ename from emp;
Begin
Open c1;
Fetch c1 bulk collect into L_ename;
Close c1;
For i in L_ename.first .. L_ename.last loop
DBMS_OUTPUT.PUT_LINE(L_ename(i));
END loop;
END;
/
*REF CURSOR:
A ref cursor is basically a data type.
A variable created based on such a data type is generally called a
cursor variable.
A ref cursor can be associated with more than one select statement
at run time. Before associating a new select statement. we need to
close the cursor.
Ex:
Declare
Type r_cursor is REF cursor;
C_emp r_cursor;
Type rec_emp is record{
name varchar2(20);
sal number(6);
};
er rec_emp;
begin
open c_emp for select ename, sal from emp where deptno = 10;
DBMS_OUTPUT.PUT_LINE(department: 10);
DBMS_OUTPUT.PUT_LINE();
Loop
Fetch c_emp into er;
Exit when c_emp%notfound;
DBMS_OUTPUT.PUT_LINE(er.name||..||er.sal);
End loop;
Close c_emp;
Open c_emp for select ename, sal from emp where deptno = 20;
Page 105 of 110
DBMS_OUTPUT.PUT_LINE(department: 20);
DBMS_OUTPUT.PUT_LINE(..);
Loop
Fetch c_emp into er;
Exit when c_emp%notfound;
DBMS_OUTPUT.PUT_LINE(er.name||-||er.sal);
End loop;
Close c_emp;
END;
/
SQL * loader:
SQL loader is a tool which is use to load the data from the file to the
table.
This tool requires control file(.Ctrl).
Control file contains all the information about source and destination.
It is developer responsibility to create a control file.
Syntax to create control file:
LOAD data
Infile <Data filepath>
Insert into table <Table_name> fields Terminated by ,
(col1, col2,., clon)
Ex:
LOAD data
INFILE E:\sunil\student_data.txt
Insert into table sutdent50 fields terminated by ,
(sno, sname, marks)
Steps to invoke the tool:
Step 1: open the command prompt.
Step 2: >SQLLDR SCOTT/TIGER
CONTROL: E:\SUNIL\Load.CTL
*Autonomous transactions:
In general a commit command used in a PL/SQL block will act globally
and make all the changes permanent.
To restrict commit command to a specific program we need to make
the PL/SQL block autonomous.
We can create autonomous PL/SQL block by using PRAGMA
AUTONOMOUS_TRAN SACTION in the declare section.
Page 106 of 110
end loop;
end;
/
*Managing large objects:
*Creating table with LDB columns:
Ex: create table airbus_desc5(airbusno char(5), airbus_det bfile,
airbus_profile clob);
*Insert values in lobs: To insert values in the bfile, the function
bfilename is used.
It takes the os path of the directory and the name of the file.
Ex:
Insert
into
airbus_desc5
bfilename(E:\sunil,esert.jpg),
the description the plane is as follows);
values(ABO1,