SlideShare a Scribd company logo
SQL Fundamentals
Oracle 11g
M U H A M M A D WA H E E D
O R AC L E D ATA BA S E D E V E LO P E R
E M A I L : m .wa h e e d 3 6 6 8 @ g m a i l . co m
.
1
Lecture#4
2
Question#1
Create doctor table (lisence no., name,
qualification,salary,contact no.,cnic,employee no.) using
column level constraints.
i- salary needs to be in currency format e.g 200000.00
ii- salary can’t be less than 10000
iii- employee no. is linked with employee table with same
field name.
3
Solution#1
SQL>CREATE TABLE doctor
2 (license_no int,
3 name varchar2(100),
4 qualification varchar2(100),
5 salary NUMBER(10,2) CHECK (salary >=10000),
6 contact_no INT,
7 cnic INT,
8 employee_no INT REFERENCES employee);
4
Question#2
Create a table lawyer(lawyer no., name, no of cases, office address,
contact no) using column level as well as table level constraints where
necessary.
i- each lawyer must have a unique id
ii- each lawyer name is required
iii- no. of cases can not be zero
iii- each lawyer have either different contact number or none.
5
Solution#2
SQL>CREATE TABLE lawyer
2 (lawyer_no INT PRIMARY KEY,
3 name VARCHAR2(100) NOT NULL,
4 no_of_cases INT CHECK (no_of_cases>0),
5 office_address VARCHAR2(200),
6 contact_no INT
7 ,
8 CONSTRAINT lawyer_contact_uk UNIQUE(contact_no));
6
DATA MANIPULATION
LANGUAGE (DML)
•INSERT
•SELECT
•UPDATE
•DELETE
7
CRUD Operations (DML)
•CRUD represents an acronym for the database
operations Create, Read, Update, and Delete.
•Create (known as Insert)
•Read/Retrieve ( known as Select)
•Update (Update)
•Delete (Delete)
*Note: CRUD operations are effected by integrity
constraints.
8
Insert Statement
•We use following syntax:
•INSERT INTO <table_name> (<column1>,<column2>,….,<columnN>)
VALUES (<value1>,<value2>,….,<valueN>);
OR
•INSERT INTO <table_name>
VALUES (value1,value2,….);
OR
•INSERT ALL
INTO <table_name> VALUES(<column1>,<column2>,….,<columnN>)
INTO <table_name> VALUES(<column1>,<column2>,….,<columnN>)
INTO <table_name> VALUES(<column1>,<column2>,….,<columnN>)
SELECT * FROM DUAL;
9
SELECT Statement
•Syntax:
SELECT *|<column_name(s)> FROM <table_name>
[WHERE <condition>];
•Example:
SELECT * FROM student;
or
SELECT std_id,std_name FROM student;
or
SELECT * FROM student
WHERE dept_id=10;
10
Capabilities of SELECT
11
Capabilities of SELECT
•Projection
a part of SQL statement after SELECT keyword is called “Projection” and
it refers to the consideration or elimination of columns.
•Selection
the part of SQL statement after WHERE keyword is called “Selection”
and it refers to the consideration or elimination of rows.
•In previous mentioned example “*” refers to projection and
“dept_id=10” refers to selection.
•Join
it is used to bring together data that is stored in different by creating a
link between them. You learn more about Joins in later lesson.
12
TOTAL USER_TABLES
•SELECT TABLE_NAME/* FROM TAB;
OR
SELECT TABLE_NAME FROM USER_TABLES;
13
Line Size
•You can set the number of output lines to be displayed on output
screen.
•Syntax:
SET LINESIZE n;
n is the number of vertical lines to be displayed simultaneously on
screen.
14
Motivational Speaking
15
UPDATE STATEMENT
•Modify existing records with UPDATE statement.
•Syntax:
UPDATE <table_name>
SET <column_name> = <column_value>, …….
[WHERE <condition>];
•Condition is optional part.
16
DELETE STATEMENT
•DELETE is used to either removing table contents or specific rows.
•Syntax:
DELETE FROM <table_name>
[WHERE <condition>];
17
Difference btw Delete & Truncate
Statement
•Delete is a DML command and Truncate is a DDL command.
•We can ROLLBACK the DELETE action but can't do for
truncate.
•Delete uses WHERE clause to delete specific rows while
truncate deletes whole table records.
18
Transaction Control
Language(TCL) Commands
19
COMMIT
•Ends the current transaction by making
all pending data changes permanent.
•Syntax:
COMMIT;
20
SAVEPOINT
•Marks a savepoint within current
transaction.
•Syntax:
SAVEPOINT <savepoint_name>;
21
ROLLBACK
•Ends the current transaction by discarding all pending data changes.
•Syntax:
ROLLBACK;
or
ROLLBACK TO SAVEPOINT <savepoint_name>;
•Example:
22
TCL Operational Structure
23
Your Suggestions?
24
Give your feedback at: m.waheed3668@gmail.com

More Related Content

What's hot (19)

ODP
Sql commands
Balakumaran Arunachalam
 
PPTX
STRUCTURE OF SQL QUERIES
VENNILAV6
 
PPTX
Creating database using sql commands
Belle Wx
 
PPTX
Sql server ___________session_16(views)
Ehtisham Ali
 
PDF
Sql commands
Mohd Tousif
 
PDF
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
PPTX
SQL Basics
Hammad Rasheed
 
PPTX
DDL,DML,SQL Functions and Joins
Ashwin Dinoriya
 
PPT
SQL Tutorial - Basic Commands
1keydata
 
PPT
Constraints In Sql
Anurag
 
PPT
Sql DML
Vikas Gupta
 
PPTX
Commands of DML in SQL
Ashish Gaurkhede
 
PPTX
Advanced SQL Webinar
Ram Kedem
 
PPTX
Null values, insert, delete and update in database
Hemant Suthar
 
PPT
Mysql
TSUBHASHRI
 
PPTX
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
PDF
Sql integrity constraints
Vivek Singh
 
PPTX
introdution to SQL and SQL functions
farwa waqar
 
STRUCTURE OF SQL QUERIES
VENNILAV6
 
Creating database using sql commands
Belle Wx
 
Sql server ___________session_16(views)
Ehtisham Ali
 
Sql commands
Mohd Tousif
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
SQL Basics
Hammad Rasheed
 
DDL,DML,SQL Functions and Joins
Ashwin Dinoriya
 
SQL Tutorial - Basic Commands
1keydata
 
Constraints In Sql
Anurag
 
Sql DML
Vikas Gupta
 
Commands of DML in SQL
Ashish Gaurkhede
 
Advanced SQL Webinar
Ram Kedem
 
Null values, insert, delete and update in database
Hemant Suthar
 
Mysql
TSUBHASHRI
 
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
Sql integrity constraints
Vivek Singh
 
introdution to SQL and SQL functions
farwa waqar
 

Similar to Data Manipulation(DML) and Transaction Control (TCL) (20)

DOCX
DBMS LAB M.docx
SuhaniSinha9
 
PDF
SQL command for daily use ddl dml dcl dql
kashyapdaksh29
 
PDF
Sql wksht-2
Mukesh Tekwani
 
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SabrinaShanta2
 
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SaiMiryala1
 
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
BhupendraShahi6
 
PPTX
Lab
neelam_rawat
 
PPTX
lect 2.pptx
HermanGaming
 
PPTX
2. DBMS Experiment - Lab 2 Made in SQL Used
TheVerse1
 
PPTX
DBMS week 2 hjghg hvgfhgf,3 BSCS 6th.pptx
universalcomputer1
 
PPT
Db1 lecture4
Sherif Gad
 
PPTX
DDL(Data defination Language ) Using Oracle
Farhan Aslam
 
PPTX
SQL command practical power point slides, which help you in learning sql.pptx
macivem311
 
DOC
Oracle
Rajeev Uppala
 
PDF
Rdbms day3
Nitesh Singh
 
PDF
Oracle OCP 1Z0-007题库
renguzi
 
PDF
1 z0 047
Md. Shamsul haque
 
PPTX
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
sdnsdf
 
PPT
01 basic orders
Soufiane Hakam
 
DOC
Module 3
cs19club
 
DBMS LAB M.docx
SuhaniSinha9
 
SQL command for daily use ddl dml dcl dql
kashyapdaksh29
 
Sql wksht-2
Mukesh Tekwani
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SabrinaShanta2
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SaiMiryala1
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
BhupendraShahi6
 
lect 2.pptx
HermanGaming
 
2. DBMS Experiment - Lab 2 Made in SQL Used
TheVerse1
 
DBMS week 2 hjghg hvgfhgf,3 BSCS 6th.pptx
universalcomputer1
 
Db1 lecture4
Sherif Gad
 
DDL(Data defination Language ) Using Oracle
Farhan Aslam
 
SQL command practical power point slides, which help you in learning sql.pptx
macivem311
 
Rdbms day3
Nitesh Singh
 
Oracle OCP 1Z0-007题库
renguzi
 
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
sdnsdf
 
01 basic orders
Soufiane Hakam
 
Module 3
cs19club
 
Ad

Recently uploaded (20)

PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Ad

Data Manipulation(DML) and Transaction Control (TCL)

  • 1. SQL Fundamentals Oracle 11g M U H A M M A D WA H E E D O R AC L E D ATA BA S E D E V E LO P E R E M A I L : m .wa h e e d 3 6 6 8 @ g m a i l . co m . 1 Lecture#4
  • 2. 2
  • 3. Question#1 Create doctor table (lisence no., name, qualification,salary,contact no.,cnic,employee no.) using column level constraints. i- salary needs to be in currency format e.g 200000.00 ii- salary can’t be less than 10000 iii- employee no. is linked with employee table with same field name. 3
  • 4. Solution#1 SQL>CREATE TABLE doctor 2 (license_no int, 3 name varchar2(100), 4 qualification varchar2(100), 5 salary NUMBER(10,2) CHECK (salary >=10000), 6 contact_no INT, 7 cnic INT, 8 employee_no INT REFERENCES employee); 4
  • 5. Question#2 Create a table lawyer(lawyer no., name, no of cases, office address, contact no) using column level as well as table level constraints where necessary. i- each lawyer must have a unique id ii- each lawyer name is required iii- no. of cases can not be zero iii- each lawyer have either different contact number or none. 5
  • 6. Solution#2 SQL>CREATE TABLE lawyer 2 (lawyer_no INT PRIMARY KEY, 3 name VARCHAR2(100) NOT NULL, 4 no_of_cases INT CHECK (no_of_cases>0), 5 office_address VARCHAR2(200), 6 contact_no INT 7 , 8 CONSTRAINT lawyer_contact_uk UNIQUE(contact_no)); 6
  • 8. CRUD Operations (DML) •CRUD represents an acronym for the database operations Create, Read, Update, and Delete. •Create (known as Insert) •Read/Retrieve ( known as Select) •Update (Update) •Delete (Delete) *Note: CRUD operations are effected by integrity constraints. 8
  • 9. Insert Statement •We use following syntax: •INSERT INTO <table_name> (<column1>,<column2>,….,<columnN>) VALUES (<value1>,<value2>,….,<valueN>); OR •INSERT INTO <table_name> VALUES (value1,value2,….); OR •INSERT ALL INTO <table_name> VALUES(<column1>,<column2>,….,<columnN>) INTO <table_name> VALUES(<column1>,<column2>,….,<columnN>) INTO <table_name> VALUES(<column1>,<column2>,….,<columnN>) SELECT * FROM DUAL; 9
  • 10. SELECT Statement •Syntax: SELECT *|<column_name(s)> FROM <table_name> [WHERE <condition>]; •Example: SELECT * FROM student; or SELECT std_id,std_name FROM student; or SELECT * FROM student WHERE dept_id=10; 10
  • 12. Capabilities of SELECT •Projection a part of SQL statement after SELECT keyword is called “Projection” and it refers to the consideration or elimination of columns. •Selection the part of SQL statement after WHERE keyword is called “Selection” and it refers to the consideration or elimination of rows. •In previous mentioned example “*” refers to projection and “dept_id=10” refers to selection. •Join it is used to bring together data that is stored in different by creating a link between them. You learn more about Joins in later lesson. 12
  • 13. TOTAL USER_TABLES •SELECT TABLE_NAME/* FROM TAB; OR SELECT TABLE_NAME FROM USER_TABLES; 13
  • 14. Line Size •You can set the number of output lines to be displayed on output screen. •Syntax: SET LINESIZE n; n is the number of vertical lines to be displayed simultaneously on screen. 14
  • 16. UPDATE STATEMENT •Modify existing records with UPDATE statement. •Syntax: UPDATE <table_name> SET <column_name> = <column_value>, ……. [WHERE <condition>]; •Condition is optional part. 16
  • 17. DELETE STATEMENT •DELETE is used to either removing table contents or specific rows. •Syntax: DELETE FROM <table_name> [WHERE <condition>]; 17
  • 18. Difference btw Delete & Truncate Statement •Delete is a DML command and Truncate is a DDL command. •We can ROLLBACK the DELETE action but can't do for truncate. •Delete uses WHERE clause to delete specific rows while truncate deletes whole table records. 18
  • 20. COMMIT •Ends the current transaction by making all pending data changes permanent. •Syntax: COMMIT; 20
  • 21. SAVEPOINT •Marks a savepoint within current transaction. •Syntax: SAVEPOINT <savepoint_name>; 21
  • 22. ROLLBACK •Ends the current transaction by discarding all pending data changes. •Syntax: ROLLBACK; or ROLLBACK TO SAVEPOINT <savepoint_name>; •Example: 22