SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Manipulating Data in Tables
Ms. Amrit Kaur
gamritkaur@live.com
Storing Data in a Table
• The data that you can add in a table is a row.
• INSERT Statement is used to add row in a
table.
INSERT INTO tablename [column_list)]
VALUES ( {value_list | select_statement})
• Inserting New Data
• Inserting Partial Data
• Copying Data from Existing Table
• Inserting Data Interactively
– substitution operator (&) is used for reading data
from keyboard.
Guidelines for Inserting Rows
• The number of data values must be same as the
number of columns in the table or column list.
• The order of inserting the information must be
same as the order in which columns are listed in
table or column list
• The data type of information must match with
the data types of the column.
Storing Data Using Subqueries
INSERT INTO table_name [ (column1 [, column2 ]) ]
SELECT [ *|column1 [, column2 ]
FROM table1
[ WHERE search_condition];
UPDATING Data in a Table
• UPDATE statement is use to make changes in
an existing row(s).
• We can update one or more than one column
of a row.
UPDATE table_name
SET column_name=value [, column_name=value, ...]
[WHERE condition]
Guidelines for Updating Rows
• An update can be done only one table at a
time.
• If an update violates integrity constraints,
entire update is rollback.
• If WHERE clause is not used, all rows of a table
will be changed to new values.
Updating Data using Subqueries
UPDATE table_name
SET column_name = { new_value |
[(SELECT [*|column1[,column2
] FROM table_name) ]
[WHERE condition]
Deleting Data from a Table
• DELETE statement is used to delete row(s)
from a table.
DELETE FROM table_name
[WHERE search_condition]
• TRUNCATE statement can also be used to
delete row(s) from a table.
TRUNCATE TABLE table_name
DELETE vs TRUNCATE
• DELETE is a DML statement whereas
TRUNCATE is DDL statement.
• DELETE used to remove rows and WHERE
clause is used to remove some rows whereas
TRUNCATE command delete all rows
• DELETE operations can be rolled back whereas
TRUCATE operation cannot be rolled back.
DELETE vs TRUNCATE
• DELETE will fire trigger whereas No triggers
will be fired with TRUNCATE command.
• DELETE does not free the space containing the
table whereas TRUNCATE free space
containing table and can be used by another
table.
Delete Data using Subqueries
DELETE FROM table_name
[WHERE column_name operator
[(SELECT column_name FROM table_name [ WHERE
condition])

Weitere ähnliche Inhalte

Was ist angesagt?

Bootcamp sql fundamentals bootcamp_part1
Bootcamp   sql fundamentals  bootcamp_part1Bootcamp   sql fundamentals  bootcamp_part1
Bootcamp sql fundamentals bootcamp_part1varunbhatt23
 
Bootcamp sql fundamentals crud_part3
Bootcamp   sql fundamentals   crud_part3Bootcamp   sql fundamentals   crud_part3
Bootcamp sql fundamentals crud_part3varunbhatt23
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statementsMohd Tousif
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteAl-Mamun Sarkar
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive dataAmrit Kaur
 
SQL Readable Outputs - Oracle SQL Fundamentals
SQL Readable Outputs - Oracle SQL FundamentalsSQL Readable Outputs - Oracle SQL Fundamentals
SQL Readable Outputs - Oracle SQL FundamentalsMuhammadWaheed44
 
Database constraints
Database constraintsDatabase constraints
Database constraintsHarry Potter
 
SQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHERESQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHEREI L0V3 CODING DR
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In SqlAnurag
 
Sql delete, truncate, drop statements
Sql delete, truncate, drop statementsSql delete, truncate, drop statements
Sql delete, truncate, drop statementsVivek Singh
 
Clase 13 integridad modificada
Clase 13 integridad   modificadaClase 13 integridad   modificada
Clase 13 integridad modificadaTitiushko Jazz
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1Swapnali Pawar
 

Was ist angesagt? (18)

SQL Data Manipulation
SQL Data ManipulationSQL Data Manipulation
SQL Data Manipulation
 
MYSQL join
MYSQL joinMYSQL join
MYSQL join
 
Bootcamp sql fundamentals bootcamp_part1
Bootcamp   sql fundamentals  bootcamp_part1Bootcamp   sql fundamentals  bootcamp_part1
Bootcamp sql fundamentals bootcamp_part1
 
Bootcamp sql fundamentals crud_part3
Bootcamp   sql fundamentals   crud_part3Bootcamp   sql fundamentals   crud_part3
Bootcamp sql fundamentals crud_part3
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
 
Oracle: DML
Oracle: DMLOracle: DML
Oracle: DML
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive data
 
Sql dml & tcl 2
Sql   dml & tcl 2Sql   dml & tcl 2
Sql dml & tcl 2
 
SQL Readable Outputs - Oracle SQL Fundamentals
SQL Readable Outputs - Oracle SQL FundamentalsSQL Readable Outputs - Oracle SQL Fundamentals
SQL Readable Outputs - Oracle SQL Fundamentals
 
Commands of DML in SQL
Commands of DML in SQLCommands of DML in SQL
Commands of DML in SQL
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
SQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHERESQL-Alter Table, SELECT DISTINCT & WHERE
SQL-Alter Table, SELECT DISTINCT & WHERE
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
 
Sql delete, truncate, drop statements
Sql delete, truncate, drop statementsSql delete, truncate, drop statements
Sql delete, truncate, drop statements
 
Clase 13 integridad modificada
Clase 13 integridad   modificadaClase 13 integridad   modificada
Clase 13 integridad modificada
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 

Andere mochten auch

1195_Lebanon_publication_en_web_original
1195_Lebanon_publication_en_web_original1195_Lebanon_publication_en_web_original
1195_Lebanon_publication_en_web_originalHassan Bahani
 
Argo Studio video production
Argo Studio video productionArgo Studio video production
Argo Studio video productionOavis Or
 
Seven purposes presentation
Seven purposes presentationSeven purposes presentation
Seven purposes presentationJohn Cronin
 
Kari Valonen, Ministry of Agriculture and Forestry - Finnish preliminary view...
Kari Valonen, Ministry of Agriculture and Forestry - Finnish preliminary view...Kari Valonen, Ministry of Agriculture and Forestry - Finnish preliminary view...
Kari Valonen, Ministry of Agriculture and Forestry - Finnish preliminary view...Maa- ja metsätalousministeriö
 
Coaching skills for recruitment leaders
Coaching skills for recruitment leadersCoaching skills for recruitment leaders
Coaching skills for recruitment leadersAmanda Davies
 
Content marketing. Promocja treści w praktyce
Content marketing. Promocja treści w praktyceContent marketing. Promocja treści w praktyce
Content marketing. Promocja treści w praktyceBiokurier
 
Edm (argo)
Edm (argo)Edm (argo)
Edm (argo)Oavis Or
 
Cучасна література дитячих українських письменників національно патріотичного...
Cучасна література дитячих українських письменників національно патріотичного...Cучасна література дитячих українських письменників національно патріотичного...
Cучасна література дитячих українських письменників національно патріотичного...garasko2015
 
Mejora tu competitividad, diferénciate. A innovar se aprende...
Mejora tu competitividad, diferénciate. A innovar se aprende...Mejora tu competitividad, diferénciate. A innovar se aprende...
Mejora tu competitividad, diferénciate. A innovar se aprende...José María De la Varga
 
Rynek sklepów internetowych ze zdrową żywnością - praca podyplomowa
Rynek sklepów internetowych ze zdrową żywnością - praca podyplomowaRynek sklepów internetowych ze zdrową żywnością - praca podyplomowa
Rynek sklepów internetowych ze zdrową żywnością - praca podyplomowaPatrycja Hrabiec-Hojda
 
Guía paso a paso curso scratch (Parte I - 2016)
Guía paso a paso curso scratch (Parte I - 2016)Guía paso a paso curso scratch (Parte I - 2016)
Guía paso a paso curso scratch (Parte I - 2016)Agneta Gallardo
 

Andere mochten auch (17)

1195_Lebanon_publication_en_web_original
1195_Lebanon_publication_en_web_original1195_Lebanon_publication_en_web_original
1195_Lebanon_publication_en_web_original
 
Argo Studio video production
Argo Studio video productionArgo Studio video production
Argo Studio video production
 
Seven purposes presentation
Seven purposes presentationSeven purposes presentation
Seven purposes presentation
 
Kari Valonen, Ministry of Agriculture and Forestry - Finnish preliminary view...
Kari Valonen, Ministry of Agriculture and Forestry - Finnish preliminary view...Kari Valonen, Ministry of Agriculture and Forestry - Finnish preliminary view...
Kari Valonen, Ministry of Agriculture and Forestry - Finnish preliminary view...
 
Matthews ttip presentation gmcc nov 2015 final
Matthews ttip presentation gmcc nov 2015 finalMatthews ttip presentation gmcc nov 2015 final
Matthews ttip presentation gmcc nov 2015 final
 
Coaching skills for recruitment leaders
Coaching skills for recruitment leadersCoaching skills for recruitment leaders
Coaching skills for recruitment leaders
 
Content marketing. Promocja treści w praktyce
Content marketing. Promocja treści w praktyceContent marketing. Promocja treści w praktyce
Content marketing. Promocja treści w praktyce
 
Edm (argo)
Edm (argo)Edm (argo)
Edm (argo)
 
Cучасна література дитячих українських письменників національно патріотичного...
Cучасна література дитячих українських письменників національно патріотичного...Cучасна література дитячих українських письменників національно патріотичного...
Cучасна література дитячих українських письменників національно патріотичного...
 
Mejora tu competitividad, diferénciate. A innovar se aprende...
Mejora tu competitividad, diferénciate. A innovar se aprende...Mejora tu competitividad, diferénciate. A innovar se aprende...
Mejora tu competitividad, diferénciate. A innovar se aprende...
 
Scr msc03906 grf
Scr msc03906 grfScr msc03906 grf
Scr msc03906 grf
 
Rynek sklepów internetowych ze zdrową żywnością - praca podyplomowa
Rynek sklepów internetowych ze zdrową żywnością - praca podyplomowaRynek sklepów internetowych ze zdrową żywnością - praca podyplomowa
Rynek sklepów internetowych ze zdrową żywnością - praca podyplomowa
 
452 año 2017
452 año 2017452 año 2017
452 año 2017
 
Dossier
DossierDossier
Dossier
 
Guía paso a paso curso scratch (Parte I - 2016)
Guía paso a paso curso scratch (Parte I - 2016)Guía paso a paso curso scratch (Parte I - 2016)
Guía paso a paso curso scratch (Parte I - 2016)
 
Primer de Primària. Anglès.
Primer de Primària. Anglès.Primer de Primària. Anglès.
Primer de Primària. Anglès.
 
Zoe Zontos
Zoe ZontosZoe Zontos
Zoe Zontos
 

Ähnlich wie 2. DML_INSERT_DELETE_UPDATE

Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptxSherinRappai
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptxSherinRappai1
 
SQL Tutorial for Beginners
SQL Tutorial for BeginnersSQL Tutorial for Beginners
SQL Tutorial for BeginnersAbdelhay Shafi
 
Intro to tsql unit 9
Intro to tsql   unit 9Intro to tsql   unit 9
Intro to tsql unit 9Syed Asrarali
 
Java class 8
Java class 8Java class 8
Java class 8Edureka!
 
OracleSQLraining.pptx
OracleSQLraining.pptxOracleSQLraining.pptx
OracleSQLraining.pptxRajendra Jain
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01sagaroceanic11
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive TechandMate
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxjainendraKUMAR55
 
Bootcamp sql fundamental
Bootcamp sql fundamentalBootcamp sql fundamental
Bootcamp sql fundamentalvarunbhatt23
 

Ähnlich wie 2. DML_INSERT_DELETE_UPDATE (20)

2..basic queries.pptx
2..basic queries.pptx2..basic queries.pptx
2..basic queries.pptx
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
 
SQL Tutorial for Beginners
SQL Tutorial for BeginnersSQL Tutorial for Beginners
SQL Tutorial for Beginners
 
ADV PPT 2 LAB.pptx
ADV PPT 2 LAB.pptxADV PPT 2 LAB.pptx
ADV PPT 2 LAB.pptx
 
Manipulating data
Manipulating dataManipulating data
Manipulating data
 
Intro to tsql unit 9
Intro to tsql   unit 9Intro to tsql   unit 9
Intro to tsql unit 9
 
Java class 8
Java class 8Java class 8
Java class 8
 
OracleSQLraining.pptx
OracleSQLraining.pptxOracleSQLraining.pptx
OracleSQLraining.pptx
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Bootcamp sql fundamental
Bootcamp sql fundamentalBootcamp sql fundamental
Bootcamp sql fundamental
 
Sql2
Sql2Sql2
Sql2
 
UNIT2.ppt
UNIT2.pptUNIT2.ppt
UNIT2.ppt
 
Interview Questions.pdf
Interview Questions.pdfInterview Questions.pdf
Interview Questions.pdf
 
Babitha2.mysql
Babitha2.mysqlBabitha2.mysql
Babitha2.mysql
 
Babitha2 Mysql
Babitha2 MysqlBabitha2 Mysql
Babitha2 Mysql
 
MULTIPLE TABLES
MULTIPLE TABLES MULTIPLE TABLES
MULTIPLE TABLES
 

Mehr von Amrit Kaur

File Organization
File OrganizationFile Organization
File OrganizationAmrit Kaur
 
Introduction to transaction processing
Introduction to transaction processingIntroduction to transaction processing
Introduction to transaction processingAmrit Kaur
 
Transaction Processing
Transaction ProcessingTransaction Processing
Transaction ProcessingAmrit Kaur
 
Sample Interview Question
Sample Interview QuestionSample Interview Question
Sample Interview QuestionAmrit Kaur
 
12. oracle database architecture
12. oracle database architecture12. oracle database architecture
12. oracle database architectureAmrit Kaur
 
11. using regular expressions with oracle database
11. using regular expressions with oracle database11. using regular expressions with oracle database
11. using regular expressions with oracle databaseAmrit Kaur
 
9. index and index organized table
9. index and index organized table9. index and index organized table
9. index and index organized tableAmrit Kaur
 
8. transactions
8. transactions8. transactions
8. transactionsAmrit Kaur
 
7. exceptions handling in pl
7. exceptions handling in pl7. exceptions handling in pl
7. exceptions handling in plAmrit Kaur
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functionsAmrit Kaur
 
Chapter 8 Inheritance
Chapter 8 InheritanceChapter 8 Inheritance
Chapter 8 InheritanceAmrit Kaur
 
Chapter 7 C++ As OOP
Chapter 7 C++ As OOPChapter 7 C++ As OOP
Chapter 7 C++ As OOPAmrit Kaur
 
Chapter 6 OOPS Concept
Chapter 6 OOPS ConceptChapter 6 OOPS Concept
Chapter 6 OOPS ConceptAmrit Kaur
 
ComputerBasics
ComputerBasicsComputerBasics
ComputerBasicsAmrit Kaur
 
Security and Viruses
Security and VirusesSecurity and Viruses
Security and VirusesAmrit Kaur
 

Mehr von Amrit Kaur (20)

File Organization
File OrganizationFile Organization
File Organization
 
Introduction to transaction processing
Introduction to transaction processingIntroduction to transaction processing
Introduction to transaction processing
 
ER diagram
ER diagramER diagram
ER diagram
 
Transaction Processing
Transaction ProcessingTransaction Processing
Transaction Processing
 
Normalization
NormalizationNormalization
Normalization
 
Sample Interview Question
Sample Interview QuestionSample Interview Question
Sample Interview Question
 
12. oracle database architecture
12. oracle database architecture12. oracle database architecture
12. oracle database architecture
 
11. using regular expressions with oracle database
11. using regular expressions with oracle database11. using regular expressions with oracle database
11. using regular expressions with oracle database
 
10. timestamp
10. timestamp10. timestamp
10. timestamp
 
9. index and index organized table
9. index and index organized table9. index and index organized table
9. index and index organized table
 
8. transactions
8. transactions8. transactions
8. transactions
 
7. exceptions handling in pl
7. exceptions handling in pl7. exceptions handling in pl
7. exceptions handling in pl
 
6. triggers
6. triggers6. triggers
6. triggers
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
 
4. plsql
4. plsql4. plsql
4. plsql
 
Chapter 8 Inheritance
Chapter 8 InheritanceChapter 8 Inheritance
Chapter 8 Inheritance
 
Chapter 7 C++ As OOP
Chapter 7 C++ As OOPChapter 7 C++ As OOP
Chapter 7 C++ As OOP
 
Chapter 6 OOPS Concept
Chapter 6 OOPS ConceptChapter 6 OOPS Concept
Chapter 6 OOPS Concept
 
ComputerBasics
ComputerBasicsComputerBasics
ComputerBasics
 
Security and Viruses
Security and VirusesSecurity and Viruses
Security and Viruses
 

2. DML_INSERT_DELETE_UPDATE

  • 1. Manipulating Data in Tables Ms. Amrit Kaur gamritkaur@live.com
  • 2. Storing Data in a Table • The data that you can add in a table is a row. • INSERT Statement is used to add row in a table. INSERT INTO tablename [column_list)] VALUES ( {value_list | select_statement})
  • 3. • Inserting New Data • Inserting Partial Data • Copying Data from Existing Table • Inserting Data Interactively – substitution operator (&) is used for reading data from keyboard.
  • 4. Guidelines for Inserting Rows • The number of data values must be same as the number of columns in the table or column list. • The order of inserting the information must be same as the order in which columns are listed in table or column list • The data type of information must match with the data types of the column.
  • 5. Storing Data Using Subqueries INSERT INTO table_name [ (column1 [, column2 ]) ] SELECT [ *|column1 [, column2 ] FROM table1 [ WHERE search_condition];
  • 6. UPDATING Data in a Table • UPDATE statement is use to make changes in an existing row(s). • We can update one or more than one column of a row. UPDATE table_name SET column_name=value [, column_name=value, ...] [WHERE condition]
  • 7. Guidelines for Updating Rows • An update can be done only one table at a time. • If an update violates integrity constraints, entire update is rollback. • If WHERE clause is not used, all rows of a table will be changed to new values.
  • 8. Updating Data using Subqueries UPDATE table_name SET column_name = { new_value | [(SELECT [*|column1[,column2 ] FROM table_name) ] [WHERE condition]
  • 9. Deleting Data from a Table • DELETE statement is used to delete row(s) from a table. DELETE FROM table_name [WHERE search_condition] • TRUNCATE statement can also be used to delete row(s) from a table. TRUNCATE TABLE table_name
  • 10. DELETE vs TRUNCATE • DELETE is a DML statement whereas TRUNCATE is DDL statement. • DELETE used to remove rows and WHERE clause is used to remove some rows whereas TRUNCATE command delete all rows • DELETE operations can be rolled back whereas TRUCATE operation cannot be rolled back.
  • 11. DELETE vs TRUNCATE • DELETE will fire trigger whereas No triggers will be fired with TRUNCATE command. • DELETE does not free the space containing the table whereas TRUNCATE free space containing table and can be used by another table.
  • 12. Delete Data using Subqueries DELETE FROM table_name [WHERE column_name operator [(SELECT column_name FROM table_name [ WHERE condition])