3 min read•august 6, 2024
SQL's Data Definition Language (DDL) lets you and modify structures. You'll learn how to make tables, set types, and add values. These skills are crucial for building a solid database foundation.
Altering existing database objects is also key. You'll discover how to tables, rename columns, and even delete entire structures. Understanding these operations helps you adapt your database as needs evolve.
CREATE [TABLE](https://www.fiveableKeyTerm:table)
statement to define a new table in a database
CREATE TABLE employees (id [INT](https://www.fiveableKeyTerm:int), name [VARCHAR](https://www.fiveableKeyTerm:varchar)(50), salary [DECIMAL](https://www.fiveableKeyTerm:decimal)(10,2))
CREATE DATABASE
statement creates a new database
CREATE DATABASE company_db
id INT [PRIMARY KEY](https://www.fiveableKeyTerm:Primary_Key), name VARCHAR(50) [NOT NULL](https://www.fiveableKeyTerm:not_null)
DEFAULT
keyword allows specifying a default value for a column
CREATE TABLE products (id INT, name VARCHAR(50), price DECIMAL(10,2) DEFAULT 0.00)
[AUTO_INCREMENT](https://www.fiveableKeyTerm:auto_increment)
is an attribute used for integer columns to automatically generate sequential numbers
CREATE TABLE orders (id INT AUTO_INCREMENT PRIMARY KEY, customer_id INT, order_date DATE)
[ALTER TABLE](https://www.fiveableKeyTerm:alter_table)
statement modifies the structure of an existing table
[ALTER](https://www.fiveableKeyTerm:Alter) TABLE employees ADD COLUMN email VARCHAR(100)
ALTER TABLE
:
CHANGE
keyword followed by the old column name, new column name, and data typeALTER TABLE employees CHANGE COLUMN salary emp_salary DECIMAL(10,2)
ALTER TABLE
:
[DROP COLUMN](https://www.fiveableKeyTerm:drop_column)
keyword followed by the column nameALTER TABLE employees DROP COLUMN age
DROP TABLE
statement removes an existing table from the database
DROP TABLE employees
DROP TABLE
as it irreversibly deletes the table and its contents