Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why alter command is referred as DDL and not DML?

Tags:

sql

dml

ddl

alter

I was going through the different commands in SQL and I came across alter command which is referred as DDL (Data Definition Language). We can alter the column and values in it, so we can manipulate the data with this command so why does alter command is not referred as DML (Data Manipulation Language).

I have googled and I can not come across some good explanation, so please help me with this.

like image 450
Lakshaya Maheshwari Avatar asked Feb 07 '23 20:02

Lakshaya Maheshwari


2 Answers

ALTER command is used to alter the structure of the database. And this is what DDL does i.e., DDL statements are used to define the database structure or schema.

Whereas DML statement is used to manage data within schema objects.

like image 163
Rahul Tripathi Avatar answered Feb 11 '23 07:02

Rahul Tripathi


DDL - alter the schema.

This including creating tables, renaming columns, dropping views, etc. Such statements are DDL even though such might create (default value), alter (by conversion), or even lose (removed column) data as part of the process. Basically, any CREATE/DROP/ALTER command is DDL.

DML - alter the information/data within the schema; without updating the schema.

This includes DELETE and UPDATE statements.

Sometimes DDL and DML must be used together to correctly migrate a schema; but they are two distinct categories of SQL commands, and DML never causes the schema to be changed.

like image 27
user2864740 Avatar answered Feb 11 '23 07:02

user2864740