All Exams Test series for 1 year @ ₹349 only
Question

Which of the following statements are DML statements?

(a) Update [tablename] Set [columnname] = VALUE

(b) Delete [tablename]

(c) Select * from [tablename]

The correct answer is

(a), (b) and (c)

Understanding SQL DML Statements

SQL (Structured Query Language) commands are broadly categorized based on their function. One of the main categories is Data Manipulation Language (DML). DML statements are used for managing data within schema objects. In simpler terms, they are the commands you use to work with the actual data stored in your database tables.

Let's examine the statements provided in the question to determine which ones belong to the DML category.

The statements are:

  1. Update [tablename] Set [columnname] = VALUE
  2. Delete [tablename]
  3. Select * from [tablename]

Analyzing Each Statement

Statement (a): Update

The UPDATE statement is used to modify existing records in a database table. It allows you to change the values in one or more columns for rows that match a specified condition (or for all rows if no condition is given). Since this command directly changes the data stored in the table, it is classified as a Data Manipulation Language (DML) statement.

Example:

UPDATE Employees SET Salary = 60000 WHERE EmployeeID = 101;

This command updates the Salary for a specific employee, directly manipulating the data.

Statement (b): Delete

The DELETE statement is used to remove one or more rows from a table. You can specify criteria using a WHERE clause to remove specific rows, or you can delete all rows from the table. Removing data is a form of manipulating the data within the database. Therefore, the DELETE statement is also classified as a Data Manipulation Language (DML) statement.

Example:

DELETE FROM Orders WHERE OrderID = 2005;

This command removes a specific order record, manipulating the data by deleting it.

Statement (c): Select

The SELECT statement is used to retrieve data from one or more tables. While it doesn't change the data in the database, it interacts with the data to fetch it for viewing or processing. It is the most frequently used SQL command. Retrieving data is considered a core operation for manipulating data, as you need to access and view it to decide how to manipulate it further. Thus, the SELECT statement is also categorized as a Data Manipulation Language (DML) statement.

Example:

SELECT ProductName, Price FROM Products WHERE Category = 'Electronics';

This command retrieves product names and prices, interacting with the data stored in the Products table.

Conclusion on DML Statements

Based on the analysis, all three statements provided:

  • (a) Update [tablename] Set [columnname] = VALUE
  • (b) Delete [tablename]
  • (c) Select * from [tablename]

are commands used for interacting with or manipulating the data stored within database tables. Therefore, they are all considered Data Manipulation Language (DML) statements.

SQL Command Types Revision Table

SQL commands are typically divided into several categories. Understanding these categories helps clarify the purpose of different commands like DML statements.

Category Full Form Purpose Common Commands
DML Data Manipulation Language Managing data within schema objects SELECT, INSERT, UPDATE, DELETE, MERGE, CALL, EXPLAIN PLAN, LOCK TABLE
DDL Data Definition Language Defining and managing the structure of database objects CREATE, ALTER, DROP, TRUNCATE, RENAME, COMMENT
DCL Data Control Language Controlling access to data and objects GRANT, REVOKE
TCL Transaction Control Language Managing transactions in the database COMMIT, ROLLBACK, SAVEPOINT, SET TRANSACTION

Additional Information on DML

DML statements are fundamental for any user interacting with a database's data. They allow users to query data using SELECT, add new data with INSERT, modify existing data with UPDATE, and remove data with DELETE. These operations are distinct from DDL commands, which change the database structure itself (like adding or removing a table or a column).

While SELECT is often primarily thought of as a retrieval command, its classification as DML is due to its interaction with the data content. It is used in conjunction with other DML commands (like in subqueries for INSERT, UPDATE, or DELETE statements) and operates on the data records themselves.

Was this answer helpful?

Important Questions from SQL

  1. In SQL, _______ is an Aggregate function.

  2. Match the following -

    List IList II
    (a)DDL(i)LOCK TABLE
    (b)DML(ii)COMMIT
    (c)TCL(iii)Natural Difference
    (d)Binary operation(iv)REVOKE
  3. In SQL, which of the following command is used to modify a column in a table?

  4. Which of the following keyword is used to eliminate duplicate records in SQL?

  5. _______ SQL command changes one or more fields in a record.

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App