- DML commands are used to modify the database. It is responsible for all form of changes in the database.
- The command of DML is not auto-committed that means it can’t permanently save all the changes in the database. They can be rollback.
Here are some commands that come under DML:
- INSERT
- SELECT
- UPDATE
- DELETE
INSERT INTO COMMAND
The INSERT INTO
statement is used to insert new records in a table.
INSERT INTO Syntax:-
It is possible to write the INSERT INTO
statement in two ways:
- Specify both the column names and the values to be inserted:
INSERT INTO table_name (column1, column2, column3, …)
VALUES (value1, value2, value3, …);
- If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query. However, make sure the order of the values is in the same order as the columns in the table.
INSERT INTO table_name
VALUES (value1, value2, value3, …);
Example
Select Command
The SELECT
statement is used to select data from a database.
The data returned is stored in a result table, called the result-set.
SELECT Syntax
SELECT column1, column2, …
FROM table_name;
The following SQL statement selects all the columns
SELECT * FROM Table_name;
Example
Update Command
The UPDATE
statement is used to modify the existing records in a table.
UPDATE Syntax
UPDATE table_name
SET column1 = value1, column2 = value2, …
WHERE condition;
Example
Delete Command
The DELETE
statement is used to delete existing records in a table.
DELETE Syntax:-
DELETE FROM table_name WHERE condition;
Example