DDL
DDL changes database structure
DDL — Data Definition Language — groups statements that work with database structure. They create tables and other objects, change their definitions, or remove them.
CREATE TABLE users (
id INTEGER,
name VARCHAR(100)
);
CREATE TABLE creates a new table and lists its columns. For now, we specify only names and types; integrity rules for columns are covered separately.
ALTER and DROP
When the structure of an existing table needs to change, ALTER TABLE is used. For example, a new column can be added:
ALTER TABLE users
ADD COLUMN email VARCHAR(200);
The DROP TABLE statement removes the table as a database object. This changes the schema rather than deleting individual rows.
DDL statements can be destructive.
Changing or removing structure can affect existing data. Before running such statements, make sure you understand which object is being changed and whether the data can be safely recovered.
Check yourself
Exercise review
The mentor knows the solution and will help you reach it independently
Sign in to use the Mentor
The Mentor uses the current exercise and your conversation history.
Sign in
Review the key nuances and the answer after making your own attempt.
Sign in to view the solution
The solution and explanation are available after signing in.
Sign in