You are on page 1of 2

6 Lesson 6 : Data Manipulation Language

SQL is equipped with data manipulation language (DML) that is responsible for all forms data
modification in a database by either inserting, updating, or deleting the data. SQL contains the
following set of DML commands.

 INSERT INTO/VALUES
 UPDATE/SET/WHERE
 DELETE FROM/WHERE
These basic constructs allow database users to enter data into the database and modify the data
efficiently using a number of filter options.

INSERT INTO/VALUES
This command is used for inserting values into the rows of a table (relation).

Syntax−
INSERT INTO table (column1 [, column2, column3 ... ]) VALUES
(value1 [, value2, value3 ... ])
Or
INSERT INTO table VALUES (value1, [value2, ... ])
In the first case, only the values for the specified columns are required. The columns can be specified
in whichever order provided that the corresponding values are also specified in the same order.
However, all attributes defined with a NOT NULL constraint must be included.

In the second case, all table values must be supplied and in the exact order as they are defined

For example −
INSERT INTO programs (program_name, program_level)
VALUES (‘Bachelor of Commerce’, ‘Undergraduate’);

UPDATE/SET/WHERE
This command is used for updating or modifying existing data in a table (relation).

Syntax −
UPDATE table_name SET column_name = value [, column_name =
value ...] [WHERE condition]
For example −
UPDATE programs
SET program_level=’Certificate’
WHERE program_name like ‘Certifi%’;

DELETE/FROM/WHERE
This command is used for removing one or more rows from a table (relation).

1
Syntax −
DELETE FROM table_name [WHERE condition];
For example −
DELETE FROM programs WHERE program_name="test program";

Note: The TRUNCATE TABLE statement can also be used to delete all the data inside a table, without
deleting the table structure.

For example −
TRUNCATE TABLE programs;

You might also like