0% found this document useful (0 votes)
21 views12 pages

Working With Tables: Data Management and Retrieval: Samia Arshad

The document explains the Data Manipulation Language (DML) in SQL, which includes the INSERT, UPDATE, and DELETE statements for managing data in tables. It details how to add new rows using the INSERT statement, update existing rows with the UPDATE statement, and delete rows with the DELETE statement, including syntax and examples for each operation. Additionally, it covers the formatting of data types when inserting records.

Uploaded by

shaisch5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views12 pages

Working With Tables: Data Management and Retrieval: Samia Arshad

The document explains the Data Manipulation Language (DML) in SQL, which includes the INSERT, UPDATE, and DELETE statements for managing data in tables. It details how to add new rows using the INSERT statement, update existing rows with the UPDATE statement, and delete rows with the DELETE statement, including syntax and examples for each operation. Additionally, it covers the formatting of data types when inserting records.

Uploaded by

shaisch5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Working with Tables:

Data Management and


Retrieval

SAMIA ARSHAD
DATA MANIPULATION
LANGUAGE (DML)
 SQL language’s Data Manipulation
Language (DML) consists of three
statements:
 INSERT
 UPDATE
 DELETE
DATA MANIPULATION
LANGUAGE (DML)
 A new row is added to a table with
the INSERT statement
 The DELETE statement removes
row(s) from a table.
 Data in existing row(s) is/are
changed with the UPDATE
statement.
ADDING A NEW
ROW/RECORD
 The Data Manipulation Language (DML)
statement INSERT is used to insert a
new row/record into a table.

 The general syntax for the INSERT


statement is as follows:
INSERT INTO tablename [(column1, column2,
column3,...)]
VALUES (value1, value2, value3,...);
ADDING A NEW
ROW/RECORD
 The column names are optional. If column
names are omitted from the INSERT statement,
you must enter a value for each column.

 If you know the order of column names in


correct order, you can enter values in the
same order following the VALUES keyword.
ADDING A NEW
ROW/RECORD
 If you do enter column names, they do
not have to be in the same order as
they were defined in table’s structure at
the time of creation.

INSERT INTO student (StudentID, LAST,


FIRST, ZIP, Bdate, FacultyID)
VALUES (00100, ‘Will’, ‘Smith’, 72034, ’12-
FEB-80’, 123)
ADDING A NEW
ROW/RECORD
 When entering values, numeric
data is not enclosed within quotes

 The character and date type


values are enclosed within single
quotes.

 The default format to enter the


date value is ‘YYYY-MM-DD’.
UPDATING EXISTING
ROWS/RECORDS
 In SQL, the UPDATE statement is used to
modify data.
 Only one table can be updated at one
time.
 It is possible to change more than one
column at a time

UPDATE tablename
SET column1 = newvalue , column2
= newvalue
WHERE condition(s);
UPDATING EXISTING
ROWS/RECORDS
 The condition is optional, but it is
necessary

 Suppose the student with ID 00103 in


the IU college’s database switches
major from BS---CS to BS---EE

UPDATE student
Set MajorID = 700
Where studentid=00103
DELETING EXISTING
ROWS/RECORDS
 Deletion is another data
maintenance operation.
 the SQL statement DELETE is used
for deleting unwanted rows. Its
general syntax is

DELETE FROM tablename


[WHERE condition(s)];
DELETING EXISTING
ROWS/RECORDS
 Example:

DELETE FROM dept


WHERE DeptID = 70
Insert multiple statements
insert all
into p7 values(115,'name')
into p7 values(116,'name1')
select * from dual;

You might also like