Home

Ddl

Data Definition Language (DDL) is a subset of SQL used to define and manage the structure of database objects, such as schemas, tables, views, indexes, and constraints. DDL commands affect the schema rather than the data and are distinct from Data Manipulation Language (DML), which handles data queries and updates, and from Data Control Language (DCL) and Transaction Control Language (TCL).

The core DDL statements include CREATE, ALTER, DROP, TRUNCATE, and RENAME. CREATE defines new objects, such as

DDL statements are executed by the database engine and modify the database schema, updating system catalogs

Transactional behavior for DDL varies by database. In many systems, DDL is treated as an auto-commit operation

Examples include: CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(100), hire_date DATE); ALTER TABLE employees

a
table
or
index.
ALTER
modifies
existing
objects,
for
example
by
adding
or
changing
a
column
or
constraint.
DROP
removes
objects
from
the
database.
TRUNCATE
quickly
removes
all
rows
from
a
table
while
preserving
its
structure,
and
RENAME
changes
an
object's
identifier.
Some
systems
also
support
metadata
or
comment
statements
to
annotate
database
objects,
though
the
exact
syntax
can
vary
by
database
system.
or
data
dictionaries.
They
often
require
locks
and
can
affect
dependent
objects,
permissions,
constraints,
and
triggers.
Because
they
change
the
structure
of
the
database,
their
behavior
and
impact
are
typically
more
disruptive
than
standard
data
updates.
and
cannot
be
rolled
back
within
a
transaction,
though
some
modern
relational
databases
provide
transactional
DDL
semantics
within
a
single
transaction
boundary.
ADD
COLUMN
department
VARCHAR(50);
DROP
TABLE
employees;
TRUNCATE
TABLE
employees.
Syntax
and
capabilities
differ
among
database
products,
so
consultation
of
vendor
documentation
is
recommended.