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

PPT
SQL introduction
PDF
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
PPT
MySQL Built-In Functions
 
PPT
MySQL lecture
PDF
Become a super modeler
PDF
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
SQL introduction
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
MySQL Built-In Functions
 
MySQL lecture
Become a super modeler
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스

What's hot (20)

PPTX
DBMS information in detail || Dbms (lab) ppt
PDF
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
DOC
Sql queries
PDF
Efficient Pagination Using MySQL
PDF
Joining tables
PPT
Sqlxml vs xquery
PDF
PostgreSQL 9.6 새 기능 소개
DOCX
Materi my sql part 1
PPT
DB2 Native XML
PPT
SQL || overview and detailed information about Sql
PDF
The Ring programming language version 1.2 book - Part 17 of 84
DOC
Dbms lab Manual
PPTX
Database administration commands
TXT
Quick reference for spark sql
TXT
Oracle ORA Errors
PPT
mysqlHiep.ppt
DOCX
Tugas praktikum smbd
PDF
Tech Talk: Best Practices for Data Modeling
DBMS information in detail || Dbms (lab) ppt
ClickHouse Unleashed 2020: Our Favorite New Features for Your Analytical Appl...
Sql queries
Efficient Pagination Using MySQL
Joining tables
Sqlxml vs xquery
PostgreSQL 9.6 새 기능 소개
Materi my sql part 1
DB2 Native XML
SQL || overview and detailed information about Sql
The Ring programming language version 1.2 book - Part 17 of 84
Dbms lab Manual
Database administration commands
Quick reference for spark sql
Oracle ORA Errors
mysqlHiep.ppt
Tugas praktikum smbd
Tech Talk: Best Practices for Data Modeling
Ad

Viewers also liked (19)

DOC
PPT
Spatial Database Systems
PPTX
Direct memory access (dma) with 8257 DMA Controller
PPT
8237 / 8257 DMA
DOCX
Profil singkat pt hasindo nusa teknika
PPTX
Supply chain management new
PPTX
Business studies review
PDF
παρουσίαση 8 2
PDF
El Rol del Gerente
PPTX
PPTX
What you need to know about
PDF
Travel Insurance Direct Ireland Policy Documents
PPT
Mc ilhenny company interview questions and answers
PPTX
Tjb advertising ltd marketing
DOCX
Inplant training for_mechatronics_1
PPTX
Brazilian prezi vicky+ella+may
PPTX
Picture framing tools and equipment
PDF
Design in Mind
PPT
Sandblaster Experiment
Spatial Database Systems
Direct memory access (dma) with 8257 DMA Controller
8237 / 8257 DMA
Profil singkat pt hasindo nusa teknika
Supply chain management new
Business studies review
παρουσίαση 8 2
El Rol del Gerente
What you need to know about
Travel Insurance Direct Ireland Policy Documents
Mc ilhenny company interview questions and answers
Tjb advertising ltd marketing
Inplant training for_mechatronics_1
Brazilian prezi vicky+ella+may
Picture framing tools and equipment
Design in Mind
Sandblaster Experiment
Ad

Similar to Oracle PL-SQL (20)

PPT
Module 3 _SQL Database Management System
PDF
6_SQL.pdf
PPTX
Oracle Database 12c - New Features for Developers and DBAs
PPTX
Oracle Database 12c - New Features for Developers and DBAs
PPTX
DDL(Data defination Language ) Using Oracle
PPT
Mysql rab2-student
PPT
Mysql rab2-student
PPTX
SQL.pptx
PPTX
Adbms 21 sql 99 schema definition constraints and queries
PPTX
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
PPTX
PPTX
Sql intro
PPTX
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
PPT
Sql 2006
PDF
DBMS_sql-ddl_V1.pdf890 ddl dml dql TCL DCL
PDF
Database Management Systems s-sql-ddl.pdf
PPT
MDI Training DB2 Course
PPT
Lecture-9-10-11-12(a-b).ppt modern database
PPTX
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Module 3 _SQL Database Management System
6_SQL.pdf
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
DDL(Data defination Language ) Using Oracle
Mysql rab2-student
Mysql rab2-student
SQL.pptx
Adbms 21 sql 99 schema definition constraints and queries
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
Sql intro
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
Sql 2006
DBMS_sql-ddl_V1.pdf890 ddl dml dql TCL DCL
Database Management Systems s-sql-ddl.pdf
MDI Training DB2 Course
Lecture-9-10-11-12(a-b).ppt modern database
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...

Recently uploaded (20)

PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Construction Project Organization Group 2.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Geodesy 1.pptx...............................................
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Sustainable Sites - Green Building Construction
PPTX
Welding lecture in detail for understanding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPT
Mechanical Engineering MATERIALS Selection
PDF
Well-logging-methods_new................
PDF
PPT on Performance Review to get promotions
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
Construction Project Organization Group 2.pptx
UNIT 4 Total Quality Management .pptx
Geodesy 1.pptx...............................................
CH1 Production IntroductoryConcepts.pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
R24 SURVEYING LAB MANUAL for civil enggi
Sustainable Sites - Green Building Construction
Welding lecture in detail for understanding
Operating System & Kernel Study Guide-1 - converted.pdf
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Foundation to blockchain - A guide to Blockchain Tech
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
Mechanical Engineering MATERIALS Selection
Well-logging-methods_new................
PPT on Performance Review to get promotions

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;