Sql Ddl — Free Sql Tutorial
Learn Sql Ddl in Sql with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.
TL;DR: Learn Sql Ddl in Sql with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.
Written & reviewed by the Syllab.in Academic Team (CBSE/NCERT subject experts) · Updated
Sql Ddl in Sql
DDL (Data Definition Language) is the SQL commands that define the structure of a database: CREATE TABLE, ALTER TABLE, DROP TABLE. Understanding DDL is essential for designing databases from scratch.
Constraints: Rules that enforce data integrity. PRIMARY KEY: uniquely identifies each row, cannot be NULL or duplicate. NOT NULL: column must always have a value. UNIQUE: no duplicates allowed (but can be NULL). DEFAULT: value used if none is specified. CHECK: value must meet a condition. FOREIGN KEY: links to another table's primary key.
Good database design uses constraints to prevent bad data from entering the database — better to reject bad input at the database level than to deal with corrupted data later.
Sql Ddl — Syntax
CREATE TABLE table_name ( column1 datatype CONSTRAINT, column2 datatype CONSTRAINT, PRIMARY KEY (column1), FOREIGN KEY (column2) REFERENCES other_table(pk) ); -- Data types: INT, VARCHAR(n), DECIMAL(p,s), -- DATE, BOOLEAN, TEXT
Learn Sql Ddl step by step with Syllab's free interactive Sql tutorial — runnable code examples, practice exercises and instant AI feedback, all free with no signup. Explore the full Sql course →