Summary - CREATE TABLE
- SQL course
- Beginner
- Lesson 94/115
- 5 min
Combine column types, NOT NULL and PRIMARY KEY to build a table.
Summary - CREATE TABLE
In this group you learned CREATE TABLE, PRIMARY KEY, NOT NULL, DEFAULT and AUTO_INCREMENT. Creating tables is now easy.
CREATE TABLE products (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
stock INT DEFAULT 0
);This query creates a fully-featured products table.
The table products is created.
Practice Summary - CREATE TABLE
Create products with id INT PRIMARY KEY, name VARCHAR(100) NOT NULL.
Starter code
-- summary table
CREATE TABLE productsSample solution
CREATE TABLE products (
id INT PRIMARY KEY,
name VARCHAR(100) NOT NULL
)Expected output
Tablo oluşturuldu
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which marks a column as required?
- NOT NULL Correct answer
- NULL
- EMPTY
- ZERO
Explanation: NOT NULL marks a column as required.
2 Summary - CREATE TABLE: match the terms
| Term | Meaning |
|---|---|
CREATE TABLE |
create table |
PRIMARY KEY |
primary |
NOT NULL |
not null |
DEFAULT |
default |