What is Data definition language?
Data Definition Language (DDL) in SQL
What is Data Definition Language (DDL)?
Data Definition Language (DDL) is a set of SQL commands used to define, create, modify, and delete database structures.
DDL commands are responsible for managing database objects such as:
- Tables
- Indexes
- Views
- Schemas
- Users (in some database systems)
DDL is an important subset of SQL (Structured Query Language) used in database applications.
Common DDL Commands
Some commonly used DDL commands include:
1. CREATE
The CREATE command is used to create new database objects, such as tables or indexes.
Example:
CREATE TABLE Students (
StudentID INT,
Name VARCHAR(50),
Age INT
);
This command creates a new table named Students with specified columns.
2. ALTER
The ALTER command is used to modify an existing database object, such as adding or changing columns in a table.
Example:
ALTER TABLE Students
ADD Email VARCHAR(100);
This command creates a new table named Students with specified columns.
2. ALTER
The ALTER command is used to modify an existing database object, such as adding or changing columns in a table.
Example:
ALTER TABLE Students
ADD Email VARCHAR(100);
3. DROP
The DROP command is used to delete database objects permanently.
Example:
DROP TABLE Students;
This command deletes the Students table from the database.
Features of DDL
- DDL defines the structure of a database.
- It provides commands to create, modify, and delete database objects.
- It uses predefined SQL syntax to describe data structures.
- It allows defining column names and data types when creating tables.
- Some database systems also allow defining XML data structures using DDL.
How DDL Works
When a new table is created using SQL, the CREATE command is used along with:
- Table name
- Column names
- Data types
After creation:
- The table structure can be modified using the ALTER command.
- The table can be deleted using the DROP command.
thanks for giving answer
ReplyDeleteWelcome
DeleteMost welcome
DeleteBest site sir
Delete