You are on page 1of 7

Modification of a Table’s Contents

TCS Internal 1
Scope

 INSERT Statement
 UPDATE Statement
 DELETE Statement

TCS Internal 2
INSERT Statement

 The INSERT Statement inserts rows into a table.

It has two different forms:

 Inserting a single row


 Inserting multiple row

Examples:

Inserting a single row

INSERT INTO Project VALUES(‘p1’,’TCS’,200000.00)

Inserting multiple Row

INSERT INTO dalls_dept (dept_no, dept_name)


SELECT dept_no, dept_name
FROM department
WHERE location = ‘Dallas’

TCS Internal 3
UPDATE Statement

 The UPDATE Statement modifies values of table rows.

Example:

UPDATE works_on
SET job =‘manager’
WHERE emp_no = 18316

TCS Internal 4
DELETE Statement

 The DELETE Statement deletes rows from a table.

Example:

DELETE FROM WORKS_ON


WHERE JOB =‘manager’

TCS Internal 5
TRUNCATE Statement

 It removes all rows from the table.

 It is faster than DELETE statement.

 Immediately frees all the space occupied by that table’s data and
indexes.

 DELETE statement removes rows one at a time and logs each


deleted row as a transaction, whereas TRUNCATE TABLE doesn’t.

SYNTAX:

TRUNCATE TABLE [[database,]owner.] table_name

TCS Internal 6
Summary

 INSERT Statement
 UPDATE Statement
 DELETE Statement

TCS Internal 7

You might also like