0% found this document useful (0 votes)
5 views

ExNo 5 - DML Commands

Cse s5 lab

Uploaded by

rithulbgmi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

ExNo 5 - DML Commands

Cse s5 lab

Uploaded by

rithulbgmi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Exp:5 PRACTICE SQL MMANDS FOR DML

Some of the most important DML Commands are: INSERT INTO, SELECT, UPDATE and
DELETE.

INSERT INTO - inserts new data into a database.


Syntax:
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
Example:
INSERT INTO Customers (CustomerID, CustomerName, ContactName, Address, City,
PostalCode, Country) VALUES
(1, 'Alfreds', 'Maria', 'Obere', 'Berlin', '12209', 'Germany'),
(2, 'Ana', 'Ana', 'Avda', 'México', '05021', 'Mexico'),
(3, 'Antonio M', 'Antonio', 'Mataderos', 'México', '05023', 'Mexico'),
(4, 'Around', 'Thomas', 'Hanover Sq.', 'London', 'WA1 1DP', 'UK'),
(5, 'Berglunds', 'Christina', 'Berguvsvagen', 'Lulea', 'S-958 22', 'Sweden');

SELECT - extracts data from a database.


Syntax:
SELECT * FROM table_name;
Example:
SELECT * FROM Customers;
Output: (Draw on left side)
CustomerID CustomerName ContactName Address City PostalCode Country

1 Alfreds Maria Obere Berlin 12209 Germany


2 Ana Ana Avda México 05021 Mexico
3 Antonio M Antonio Mataderos México 05023 Mexico
4 Around Thomas Hanover Sq. London WA1 1DP UK

5 Berglunds Christina Berguvsvagen Lulea S-958 22 Sweden


UPDATE - updates data in a database.
Syntax:
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Example:
UPDATE Customers
SET ContactName = 'NewContactName', City = 'NewCity'
WHERE CustomerID = 1;
SELECT * FROM Customers;
Output: (Draw on left side)
CustomerID CustomerName ContactName Address City PostalCode Country

1 Alfreds NewContact Obere NewCity 12209 Germany


Name
2 Ana Ana Avda México 05021 Mexico
3 Antonio M Antonio Mataderos México 05023 Mexico
4 Around Thomas Hanover Sq. London WA1 1DP UK

DELETE - deletes data from a database.


Syntax:
DELETE FROM table_name
WHERE condition;
Example:
DELETE FROM Customers
WHERE CustomerID = 4;
SELECT * FROM Customers;
Output: ((Draw on left side)
CustomerID CustomerName ContactName Address City PostalCode Country

1 Alfreds NewContact Obere NewCity 12209 Germany


Name
2 Ana Ana Avda México 05021 Mexico
3 Antonio M Antonio Mataderos México 05023 Mexico

RESULT:
DML Commands executed successfully and output verified

You might also like