DML Commands

In this sub section, let us learn the usage of below commands with examples.

1. INSERT

INSERT Statement is used to insert new records into the database table.

Syntax:

INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...)

Note: Column names are optional.

Example:

Both the below ways are correct.

INSERT INTO CUSTOMERS (InsuranceID, Name, DOB, NIN, Location,email_id) VALUES ('123', 'Mango','2000-01-01','56789','LO','[email protected]')
INSERT INTO CUSTOMERS VALUES ('123', 'Mango','2000-01-01','56789','LO','[email protected]')

2. SELECT

Select statement is used to select data from database tables.

Syntax:

SELECT column1, column2, ...
FROM table_name
[where condition]

Example:

SELECT * FROM CUSTOMERS 

3. UPDATE

UPDATE statement is used to modify the existing values of records present in the database table.

Syntax:

 UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition 

Example:

UPDATE CUSTOMERS SET email_id = '[email protected]' WHERE InsuranceID='123'

4. DELETE

DELETE statement is used to delete the existing records present in the database table.

Syntax:

DELETE FROM table_name where condition

Example:

DELETE FROM CUSTOMERS where InsuranceID='123'