DML (Data Manipulation Language)
DML (Data Manipulation Language) commands are used to interact with and modify data within existing database tables. These commands allows to insert new data, update existing data, delete unwanted data, and perform bulk operations for efficiency.
INSERT
Adds new rows of data to a table.
Syntax
INSERT INTO [schema_name.]table_name ([column_list]) VALUES ([value_list]);Example
INSERT INTO Customers (CustomerID, CustomerName, Email, Phone) VALUES (1001, 'John Smith', '[email protected]', '123-456-7890');UPDATE
Modifies existing data in a table based on a specific criteria (WHERE clause).
Syntax
UPDATE [schema_table.]table_name SET [column_name] = new_value [, ...] WHERE condition;Example
UPDATE Customers SET Email = '[email protected]' WHERE CustomerID = 1002;DELETE
Removes rows of data from a table based on a specific criteria (WHERE clause).
Syntax
Example
MERGE
The MERGE statement is used to perform an "upsert" operation, which means inserting new rows into a table or updating existing rows based on specified conditions
Syntax
Example Suppose we have two tables:
employeesandemployees_updates. Theemployeestable contains the current employee data, and theemployees_updatestable contains updates to be applied to theemployeestable. We will use the MERGE statement to update theemployeestable with the data from theemployees_updatestable.
CALL
Executes a stored procedure or function in the database.
Syntax
Example
EXPLAIN PLAN
Analyzes and displays the execution plan for a SQL statement, providing insights into how the database will retrieve data.
Syntax
Example
LOCK TABLE
Explicitly locks a table or specific rows to prevent other users from modifying the data concurrently. We can release a table lock implicitly by committing or rolling back the transaction
Syntax
Example
Last updated