You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Beyond querying data with SELECT, SQL provides statements to modify data and define table structures. These are part of the Data Manipulation Language (DML) and Data Definition Language (DDL).
DDL statements define the structure of the database. The most important DDL statement at A-Level is CREATE TABLE.
CREATE TABLE TableName (
Column1 DataType CONSTRAINT,
Column2 DataType CONSTRAINT,
...
PRIMARY KEY (Column1)
);
CREATE TABLE Students (
StudentID INTEGER PRIMARY KEY,
FirstName VARCHAR(50) NOT NULL,
Surname VARCHAR(50) NOT NULL,
DateOfBirth DATE,
Email VARCHAR(100) UNIQUE,
FormGroup VARCHAR(5)
);
| Data Type | Description |
|---|---|
| INTEGER / INT | Whole numbers |
| VARCHAR(n) | Variable-length text up to n characters |
| CHAR(n) | Fixed-length text of exactly n characters |
| DATE | Date value (YYYY-MM-DD) |
| FLOAT / REAL | Decimal numbers |
| BOOLEAN | TRUE or FALSE |
| TEXT | Large text blocks |
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.