SlideShare a Scribd company logo
--BY SAURAV VERMA
-B.TECH CS 2ND
YEAR
(SGVU,JAIPUR)
COMMUNITY WORLD
Personal DBMS Vs Client/Server DBMS
Oracle 8 Environment
SQL – syntax and examples
PL/SQL-introduction
Server
Gets file requests from clients
Sends files to client
Receives files back from clients
NETWORK
Client A
Sends file requests to server
Receives files from server
Updates data
Sends files back to server
Client B
Sends file requests to server
Receives files from server
Updates data
Sends files back to server
Personal
DBMS
Demand on the client and the network
Does not perform table locking
automatically
Not fault tolerant in the case of client failure
Do not have file based transaction logging
Server
Gets data requests from clients
Adds, Deletes and updates data
Sends results to clients
NETWORK
Client A
Sends data requests to server
Receives results from server
Sends new data or changes to server
Client B
Sends data requests to server
Receives results from server
Sends new data or changes to server
Client/server
DBMS
Minimal load on the client and the network
Performs table locking automatically
Fault tolerant in the case of client failure
File based transaction logging
SQL * Plus
PL/SQL
Query Builder
Developer
Enterprise Manager
Web application server
Sqlplus username/password
ALTER USER user-name IDENTIFIED BY newpassword
START filename | @ filename
CLEAR SCREEN
HELP <command>
SAVE filename[.ext] REPLACE|APPEND
EXIT
Both an ANSI and ISO standard
Types of commands:
1. Data Definition Language (DDL) : Create, Alter, Drop,
Rename,Truncate
2. Data Manipulation Language (DML): Insert, Delete,
Update
3. Data Retrieval: Select
4. Transaction Control: Commit, Rollback, Savepoint
5. Data Control Language (DCL): Grant, Revoke
PositionPosition
IDID
PositionPosition
DescriptionDescription
11 PresidentPresident
22 ManagerManager
33 ProgrammerProgrammer
44 AccountantAccountant
55 SalesmanSalesman
QualificationQualification
IDID
QualificationQualification
DescriptionDescription
11 DoctorateDoctorate
22 MastersMasters
33 BachelorsBachelors
44 AssociatesAssociates
DeptDept
IDID
DeptDept
NameName
LocationLocation
1010 FinanceFinance CharlotteCharlotte
2020 InfosysInfosys New YorkNew York
3030 MarketingMarketing WoodbridgeWoodbridge
4040 AccountantAccountant CaliforniaCalifornia
DEPARTMENT
POSITION
QUALIFICATION
EmpEmp
IDID
LastLast
NameName
FirstFirst
NameName
PositionPosition
IDID
SuperSuper
IDID
HireHire
DateDate
SalarySalary CommComm DeptDept
IDID
QualQual
IDID
111111 SmithSmith JohnJohn 11 04/15/6004/15/60 265000265000 35003500 1010 11
246246 HoustonHouston LarryLarry 22 111111 05/19/6705/19/67 150000150000 10001000 4040 22
123123 RobertsRoberts SandiSandi 22 111111 12/02/9112/02/91 7500075000 1010 22
433433 McCallMcCall AlexAlex 33 543543 05/10/9705/10/97 6650066500 2020 44
543543 DevDev DereckDereck 22 111111 03/15/9503/15/95 8000080000 20002000 2020 11
200200 ShawShaw JinkuJinku 55 135135 01/03/0001/03/00 2450024500 30003000 3030
222222 ChenChen SunnySunny 44 123123 08/15/9908/15/99 3500035000 1010 33
135135 GarnerGarner StanleyStanley 22 111111 02/29/9602/29/96 4500045000 50005000 3030 55
EMPLOYEE
Data Definition Language:
CREATE TABLE {table}
( {column datatype [DEFAULT expr]
[column_constraint] ... | table_constraint}
[, { column datatype [DEFAULT expr]
[column_constraint] ...
)
ALTER TABLE {table}
[ADD|MODIFY {column datatype [DEFAULT expr] [column_constraint]}
[DROP drop_clause]
DROP TABLE {table} [cascade constraints]
DESC {table}
CREATE TABLE Emp
(
empid Decimal(10) NOT NULL,
positionid Number(2),
supervisorid Number(3),
deptid Number(2),
qualid Number(1),
lname varchar2(10),
fname varchar2(10),
salary Decimal(10,2),
hiredate Date,
commission Decimal(4,2),
PRIMARY KEY (empid),
FOREIGN KEY (positionid) REFERENCES Position(positionid),
FOREIGN KEY (deptid) REFERENCES Dept(deptid),
FOREIGN KEY (qualid) REFERENCES Qualification(qualid)
);
ALTER TABLE EMP MODIFY Commission decimal(7,2);
Data Manipulation Language:
INSERT INTO {table | view} [ (column [, column] ...) ]
VALUES (expr,expr ...)
UPDATE {table | view }
SET { (column [, column] = { expr | }
[WHERE condition]
DELETE [FROM] {table | view} [WHERE condition]
INSERT INTO Dept( deptid,deptname,location)
VALUES(50,'IT','Dallas');
INSERT INTO Emp(empid,
lname,fname,positionid,
supervisorid,hiredate,
salary,deptid,qualid)
VALUES(227,'howser','Barbara',4,111,'25-AUG-83',45000,10,3);
UPDATE dept SET deptname='Sales' WHERE deptID=50;
DELETE FROM dept
WHERE deptid='50';
Data Retrieval:
SELECT [DISTINCT | ALL] {table|view}
FROM {table | view}
[WHERE condition ]
[GROUP BY expr [, expr]]
[ORDER BY {expr} [ASC | DESC]]
select * from dept;
select deptname from dept where deptid='10';
select lname,fname from emp order by lname desc;
select max(salary) from emp group by positionid;
select deptname from dept,emp where
dept.deptid=emp.deptid and emp.empid='111';
Transaction Control:
COMMIT
ROLLBACK [ to {savepoint}]
SAVEPOINT {name}
commit;
savepoint point1;
rollback to point1;
Data Control Language:
GRANT [privileges]
ON object TO user|public
[WITH GRANT OPTION]
REVOKE [privileges]
ON object TO user|public
[CASCADE CONSTRAINTS]
grant select,update on emp to XYZ ;
revoke update on emp to XYZ;
A PL/SQL Example:
CREATE OR REPLACE PROCEDURE raise_salary (empno INTEGER,
increase REAL) IS
current_salary REAL;
salary_missing EXCEPTION;
BEGIN
SELECT salary INTO current_salary FROM emp WHERE emp.empid =
empno;
IF current_salary IS NULL THEN
RAISE salary_missing;
ELSE
UPDATE emp SET salary = salary + increase WHERE
emp.empid = empno;
END IF;
EXCEPTION
WHEN salary_missing THEN
UPDATE emp SET salary=0 where emp.empid=empno;
END raise_salary;

More Related Content

What's hot (20)

PPTX
DBMS information in detail || Dbms (lab) ppt
gourav kottawar
 
PDF
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
Altinity Ltd
 
DOC
Sql queries
narendrababuc
 
PDF
Efficient Pagination Using MySQL
Evan Weaver
 
PDF
Joining tables
punu_82
 
PPT
Sqlxml vs xquery
Amol Pujari
 
PDF
PostgreSQL 9.6 새 기능 소개
PgDay.Seoul
 
DOCX
Materi my sql part 1
Amar Senjaku Ofdetraisar
 
PPT
DB2 Native XML
Amol Pujari
 
PPT
SQL || overview and detailed information about Sql
gourav kottawar
 
PDF
The Ring programming language version 1.2 book - Part 17 of 84
Mahmoud Samir Fayed
 
DOC
Dbms lab Manual
Vivek Kumar Sinha
 
PPTX
Database administration commands
Varsha Ajith
 
TXT
Quick reference for spark sql
Rajkumar Asohan, PMP
 
TXT
Oracle ORA Errors
Manish Mudhliyar
 
PPT
mysqlHiep.ppt
webhostingguy
 
DOCX
Tugas praktikum smbd
Amar Senjaku Ofdetraisar
 
PDF
Tech Talk: Best Practices for Data Modeling
ScyllaDB
 
DBMS information in detail || Dbms (lab) ppt
gourav kottawar
 
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
Altinity Ltd
 
Sql queries
narendrababuc
 
Efficient Pagination Using MySQL
Evan Weaver
 
Joining tables
punu_82
 
Sqlxml vs xquery
Amol Pujari
 
PostgreSQL 9.6 새 기능 소개
PgDay.Seoul
 
Materi my sql part 1
Amar Senjaku Ofdetraisar
 
DB2 Native XML
Amol Pujari
 
SQL || overview and detailed information about Sql
gourav kottawar
 
The Ring programming language version 1.2 book - Part 17 of 84
Mahmoud Samir Fayed
 
Dbms lab Manual
Vivek Kumar Sinha
 
Database administration commands
Varsha Ajith
 
Quick reference for spark sql
Rajkumar Asohan, PMP
 
Oracle ORA Errors
Manish Mudhliyar
 
mysqlHiep.ppt
webhostingguy
 
Tugas praktikum smbd
Amar Senjaku Ofdetraisar
 
Tech Talk: Best Practices for Data Modeling
ScyllaDB
 

Viewers also liked (19)

DOC
Worst
zeal4triumph
 
PPT
Spatial Database Systems
Asifuzzaman Hridoy
 
PPTX
Direct memory access (dma) with 8257 DMA Controller
Muhammed Afsal Villan
 
PPT
8237 / 8257 DMA
AJAL A J
 
DOCX
Profil singkat pt hasindo nusa teknika
Bima Azis
 
PPTX
Supply chain management new
113080IMRAN
 
PPTX
Business studies review
Susan Hua
 
PDF
παρουσίαση 8 2
jennydav
 
PDF
El Rol del Gerente
Francys Mariana Griman
 
PPTX
E1
hollymarvell
 
PPTX
What you need to know about
Makarete10
 
PDF
Travel Insurance Direct Ireland Policy Documents
Jean Andrews
 
PPT
Mc ilhenny company interview questions and answers
KateWinslet88
 
PPTX
Tjb advertising ltd marketing
TJB Advertising
 
DOCX
Inplant training for_mechatronics_1
anushaanu3092
 
PPTX
Brazilian prezi vicky+ella+may
lozme
 
PPTX
Picture framing tools and equipment
Diyframed
 
PDF
Design in Mind
obehave
 
PPT
Sandblaster Experiment
Victoria Tran
 
Spatial Database Systems
Asifuzzaman Hridoy
 
Direct memory access (dma) with 8257 DMA Controller
Muhammed Afsal Villan
 
8237 / 8257 DMA
AJAL A J
 
Profil singkat pt hasindo nusa teknika
Bima Azis
 
Supply chain management new
113080IMRAN
 
Business studies review
Susan Hua
 
παρουσίαση 8 2
jennydav
 
El Rol del Gerente
Francys Mariana Griman
 
What you need to know about
Makarete10
 
Travel Insurance Direct Ireland Policy Documents
Jean Andrews
 
Mc ilhenny company interview questions and answers
KateWinslet88
 
Tjb advertising ltd marketing
TJB Advertising
 
Inplant training for_mechatronics_1
anushaanu3092
 
Brazilian prezi vicky+ella+may
lozme
 
Picture framing tools and equipment
Diyframed
 
Design in Mind
obehave
 
Sandblaster Experiment
Victoria Tran
 
Ad

Similar to Oracle PL-SQL (20)

DOC
Oracle
Rajeev Uppala
 
PPTX
8. sql
khoahuy82
 
PDF
dbms lab manual
stalinjothi
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
PPT
ORACLE PL SQL
Srinath Maharana
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
PDF
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
PDF
Database Management System
Hitesh Mohapatra
 
DOC
Oracle SQL AND PL/SQL
suriyae1
 
PDF
Rdbms day3
Nitesh Singh
 
DOCX
Oracle 11g SQL Overview
Prathap Narayanappa
 
PPTX
Introduction to Database SQL & PL/SQL
Collaboration Technologies
 
PPT
Sqlbysandeep
sandeepkhandare1183
 
PDF
Rdbms class test ii sep 2019
ARVIND SARDAR
 
PPT
Sql intro & ddl 1
Dr. C.V. Suresh Babu
 
PPT
Sql intro & ddl 1
Dr. C.V. Suresh Babu
 
PPTX
My SQL.pptx
KieveBarreto1
 
8. sql
khoahuy82
 
dbms lab manual
stalinjothi
 
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
ORACLE PL SQL
Srinath Maharana
 
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
Database Management System
Hitesh Mohapatra
 
Oracle SQL AND PL/SQL
suriyae1
 
Rdbms day3
Nitesh Singh
 
Oracle 11g SQL Overview
Prathap Narayanappa
 
Introduction to Database SQL & PL/SQL
Collaboration Technologies
 
Sqlbysandeep
sandeepkhandare1183
 
Rdbms class test ii sep 2019
ARVIND SARDAR
 
Sql intro & ddl 1
Dr. C.V. Suresh Babu
 
Sql intro & ddl 1
Dr. C.V. Suresh Babu
 
My SQL.pptx
KieveBarreto1
 
Ad

Recently uploaded (20)

PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PPTX
GitOps_Without_K8s_Training simple one without k8s
DanialHabibi2
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PPTX
Day2 B2 Best.pptx
helenjenefa1
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPTX
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
GitOps_Without_K8s_Training simple one without k8s
DanialHabibi2
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
MRRS Strength and Durability of Concrete
CivilMythili
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
Day2 B2 Best.pptx
helenjenefa1
 
Design Thinking basics for Engineers.pdf
CMR University
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 

Oracle PL-SQL

  • 1. --BY SAURAV VERMA -B.TECH CS 2ND YEAR (SGVU,JAIPUR) COMMUNITY WORLD
  • 2. Personal DBMS Vs Client/Server DBMS Oracle 8 Environment SQL – syntax and examples PL/SQL-introduction
  • 3. Server Gets file requests from clients Sends files to client Receives files back from clients NETWORK Client A Sends file requests to server Receives files from server Updates data Sends files back to server Client B Sends file requests to server Receives files from server Updates data Sends files back to server Personal DBMS
  • 4. Demand on the client and the network Does not perform table locking automatically Not fault tolerant in the case of client failure Do not have file based transaction logging
  • 5. Server Gets data requests from clients Adds, Deletes and updates data Sends results to clients NETWORK Client A Sends data requests to server Receives results from server Sends new data or changes to server Client B Sends data requests to server Receives results from server Sends new data or changes to server Client/server DBMS
  • 6. Minimal load on the client and the network Performs table locking automatically Fault tolerant in the case of client failure File based transaction logging
  • 7. SQL * Plus PL/SQL Query Builder Developer Enterprise Manager Web application server
  • 8. Sqlplus username/password ALTER USER user-name IDENTIFIED BY newpassword START filename | @ filename CLEAR SCREEN HELP <command> SAVE filename[.ext] REPLACE|APPEND EXIT
  • 9. Both an ANSI and ISO standard Types of commands: 1. Data Definition Language (DDL) : Create, Alter, Drop, Rename,Truncate 2. Data Manipulation Language (DML): Insert, Delete, Update 3. Data Retrieval: Select 4. Transaction Control: Commit, Rollback, Savepoint 5. Data Control Language (DCL): Grant, Revoke
  • 10. PositionPosition IDID PositionPosition DescriptionDescription 11 PresidentPresident 22 ManagerManager 33 ProgrammerProgrammer 44 AccountantAccountant 55 SalesmanSalesman QualificationQualification IDID QualificationQualification DescriptionDescription 11 DoctorateDoctorate 22 MastersMasters 33 BachelorsBachelors 44 AssociatesAssociates DeptDept IDID DeptDept NameName LocationLocation 1010 FinanceFinance CharlotteCharlotte 2020 InfosysInfosys New YorkNew York 3030 MarketingMarketing WoodbridgeWoodbridge 4040 AccountantAccountant CaliforniaCalifornia DEPARTMENT POSITION QUALIFICATION
  • 11. EmpEmp IDID LastLast NameName FirstFirst NameName PositionPosition IDID SuperSuper IDID HireHire DateDate SalarySalary CommComm DeptDept IDID QualQual IDID 111111 SmithSmith JohnJohn 11 04/15/6004/15/60 265000265000 35003500 1010 11 246246 HoustonHouston LarryLarry 22 111111 05/19/6705/19/67 150000150000 10001000 4040 22 123123 RobertsRoberts SandiSandi 22 111111 12/02/9112/02/91 7500075000 1010 22 433433 McCallMcCall AlexAlex 33 543543 05/10/9705/10/97 6650066500 2020 44 543543 DevDev DereckDereck 22 111111 03/15/9503/15/95 8000080000 20002000 2020 11 200200 ShawShaw JinkuJinku 55 135135 01/03/0001/03/00 2450024500 30003000 3030 222222 ChenChen SunnySunny 44 123123 08/15/9908/15/99 3500035000 1010 33 135135 GarnerGarner StanleyStanley 22 111111 02/29/9602/29/96 4500045000 50005000 3030 55 EMPLOYEE
  • 12. Data Definition Language: CREATE TABLE {table} ( {column datatype [DEFAULT expr] [column_constraint] ... | table_constraint} [, { column datatype [DEFAULT expr] [column_constraint] ... ) ALTER TABLE {table} [ADD|MODIFY {column datatype [DEFAULT expr] [column_constraint]} [DROP drop_clause] DROP TABLE {table} [cascade constraints] DESC {table}
  • 13. CREATE TABLE Emp ( empid Decimal(10) NOT NULL, positionid Number(2), supervisorid Number(3), deptid Number(2), qualid Number(1), lname varchar2(10), fname varchar2(10), salary Decimal(10,2), hiredate Date, commission Decimal(4,2), PRIMARY KEY (empid), FOREIGN KEY (positionid) REFERENCES Position(positionid), FOREIGN KEY (deptid) REFERENCES Dept(deptid), FOREIGN KEY (qualid) REFERENCES Qualification(qualid) ); ALTER TABLE EMP MODIFY Commission decimal(7,2);
  • 14. Data Manipulation Language: INSERT INTO {table | view} [ (column [, column] ...) ] VALUES (expr,expr ...) UPDATE {table | view } SET { (column [, column] = { expr | } [WHERE condition] DELETE [FROM] {table | view} [WHERE condition]
  • 15. INSERT INTO Dept( deptid,deptname,location) VALUES(50,'IT','Dallas'); INSERT INTO Emp(empid, lname,fname,positionid, supervisorid,hiredate, salary,deptid,qualid) VALUES(227,'howser','Barbara',4,111,'25-AUG-83',45000,10,3); UPDATE dept SET deptname='Sales' WHERE deptID=50; DELETE FROM dept WHERE deptid='50';
  • 16. Data Retrieval: SELECT [DISTINCT | ALL] {table|view} FROM {table | view} [WHERE condition ] [GROUP BY expr [, expr]] [ORDER BY {expr} [ASC | DESC]] select * from dept; select deptname from dept where deptid='10'; select lname,fname from emp order by lname desc; select max(salary) from emp group by positionid; select deptname from dept,emp where dept.deptid=emp.deptid and emp.empid='111';
  • 17. Transaction Control: COMMIT ROLLBACK [ to {savepoint}] SAVEPOINT {name} commit; savepoint point1; rollback to point1;
  • 18. Data Control Language: GRANT [privileges] ON object TO user|public [WITH GRANT OPTION] REVOKE [privileges] ON object TO user|public [CASCADE CONSTRAINTS] grant select,update on emp to XYZ ; revoke update on emp to XYZ;
  • 19. A PL/SQL Example: CREATE OR REPLACE PROCEDURE raise_salary (empno INTEGER, increase REAL) IS current_salary REAL; salary_missing EXCEPTION; BEGIN SELECT salary INTO current_salary FROM emp WHERE emp.empid = empno; IF current_salary IS NULL THEN RAISE salary_missing; ELSE UPDATE emp SET salary = salary + increase WHERE emp.empid = empno; END IF; EXCEPTION WHEN salary_missing THEN UPDATE emp SET salary=0 where emp.empid=empno; END raise_salary;