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

PDF
SQL Fundamentals - Lecture 2
PDF
Oracle SQL Fundamentals - Lecture 3
PDF
SQL Readable Outputs - Oracle SQL Fundamentals
PDF
SQL Functions - Oracle SQL Fundamentals
PDF
Basics of SELECT Statement - Oracle SQL
PPTX
Sql basic things
PPT
Sql basics and DDL statements
PPTX
Database Management - Lecture 2 - SQL select, insert, update and delete
SQL Fundamentals - Lecture 2
Oracle SQL Fundamentals - Lecture 3
SQL Readable Outputs - Oracle SQL Fundamentals
SQL Functions - Oracle SQL Fundamentals
Basics of SELECT Statement - Oracle SQL
Sql basic things
Sql basics and DDL statements
Database Management - Lecture 2 - SQL select, insert, update and delete

What's hot (19)

ODP
PPTX
STRUCTURE OF SQL QUERIES
PPTX
Creating database using sql commands
PPTX
Sql server ___________session_16(views)
PDF
Sql commands
PDF
Database Systems - SQL - DDL Statements (Chapter 3/2)
PPTX
SQL Basics
PPTX
DDL,DML,SQL Functions and Joins
PPT
SQL Tutorial - Basic Commands
PPT
Constraints In Sql
PPT
Sql DML
PPTX
Commands of DML in SQL
PPTX
Advanced SQL Webinar
PPTX
Null values, insert, delete and update in database
PPT
Mysql
PPTX
Basic sql Commands
PDF
Sql integrity constraints
PPTX
introdution to SQL and SQL functions
STRUCTURE OF SQL QUERIES
Creating database using sql commands
Sql server ___________session_16(views)
Sql commands
Database Systems - SQL - DDL Statements (Chapter 3/2)
SQL Basics
DDL,DML,SQL Functions and Joins
SQL Tutorial - Basic Commands
Constraints In Sql
Sql DML
Commands of DML in SQL
Advanced SQL Webinar
Null values, insert, delete and update in database
Mysql
Basic sql Commands
Sql integrity constraints
introdution to SQL and SQL functions
Ad

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

DOCX
DBMS LAB M.docx
PDF
SQL command for daily use ddl dml dcl dql
PDF
Sql wksht-2
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
PPTX
PPTX
lect 2.pptx
PPTX
2. DBMS Experiment - Lab 2 Made in SQL Used
PPTX
DBMS week 2 hjghg hvgfhgf,3 BSCS 6th.pptx
PPT
Db1 lecture4
PPTX
DDL(Data defination Language ) Using Oracle
PPTX
SQL command practical power point slides, which help you in learning sql.pptx
DOC
PDF
Rdbms day3
PDF
Oracle OCP 1Z0-007题库
PDF
PPTX
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
PPT
01 basic orders
DOC
Module 3
DBMS LAB M.docx
SQL command for daily use ddl dml dcl dql
Sql wksht-2
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
lect 2.pptx
2. DBMS Experiment - Lab 2 Made in SQL Used
DBMS week 2 hjghg hvgfhgf,3 BSCS 6th.pptx
Db1 lecture4
DDL(Data defination Language ) Using Oracle
SQL command practical power point slides, which help you in learning sql.pptx
Rdbms day3
Oracle OCP 1Z0-007题库
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
01 basic orders
Module 3
Ad

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
cuic standard and advanced reporting.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
Spectroscopy.pptx food analysis technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Spectral efficient network and resource selection model in 5G networks
DOCX
The AUB Centre for AI in Media Proposal.docx
Network Security Unit 5.pdf for BCA BBA.
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
cuic standard and advanced reporting.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Big Data Technologies - Introduction.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Understanding_Digital_Forensics_Presentation.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Approach and Philosophy of On baking technology
Spectroscopy.pptx food analysis technology
20250228 LYD VKU AI Blended-Learning.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Dropbox Q2 2025 Financial Results & Investor Presentation
Spectral efficient network and resource selection model in 5G networks
The AUB Centre for AI in Media Proposal.docx

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
  • 24. Your Suggestions? 24 Give your feedback at: m.waheed3668@gmail.com