Dml Commands In Sql in SQL
DML (Data Manipulation Language) commands in SQL are used to manage data within the tables. These commands allow you to insert, update, delete, and retrieve data.
? Main DML Commands:
| Command | Description |
|---|---|
| SELECT | Retrieves data from one or more tables. |
| INSERT | Adds new rows of data to a table. |
| UPDATE | Modifies existing data in a table. |
| DELETE | Removes one or more rows from a table. |
? 1. SELECT
Used to fetch data from a database.
SELECT * FROM employees;SELECT name, salary FROM employees WHERE department = 'HR';? 2. INSERT
Adds new rows to a table.
INSERT INTO employees (name, department, salary)VALUES ('John Doe', 'Sales', 45000);? 3. UPDATE
Modifies existing records.
UPDATE employeesSET salary = 50000WHERE name = 'John Doe';? 4. DELETE
Removes existing records.
DELETE FROM employeesWHERE name = 'John Doe';?? Note:
DML operations can be rolled back using the
ROLLBACKcommand.They are transactional, which means you can use
BEGIN TRANSACTION,COMMIT, andROLLBACK.
Would you like examples with a specific database table or use case?