5.7.25

Data Definition Language

Data Definition Language (DDL)

Introduction

Data Definition Language (DDL) is a subset of SQL used to define and modify the structure of a database.

DDL Commands

  • CREATE: Used to create a new database object, such as a table, index, or view.
  • ALTER: Used to modify the structure of an existing database object.
  • DROP: Used to delete a database object.
  • TRUNCATE: Used to delete all rows from a table and reset auto-incrementing IDs.

CREATE Command

  • CREATE TABLE: Used to create a new table in a database.
  • CREATE INDEX: Used to create an index on a table.
  • CREATE VIEW: Used to create a virtual table based on a query.

ALTER Command

  • ALTER TABLE: Used to modify the structure of an existing table.
  • ADD COLUMN: Used to add a new column to a table.
  • DROP COLUMN: Used to delete a column from a table.

DROP Command

  • DROP TABLE: Used to delete a table from a database.
  • DROP INDEX: Used to delete an index from a table.
  • DROP VIEW: Used to delete a view from a database.

Importance of DDL

  • Database Design: DDL is used to define the structure of a database.
  • Database Maintenance: DDL is used to modify and maintain the structure of a database.
  • Data Integrity: DDL helps ensure data integrity by defining constraints and relationships between tables.

No comments:

Post a Comment

Difference between File and Folder

10 Differences Between Files and Folders Definition: File: A collection of data or information stored on a computer. ...