CREATE TABLE in SQL
Level 5192 keystrokes
CREATE TABLE defines a new table with columns, data types, and constraints.
SQL code
-- Create a new table named products1CREATE TABLE products ( -- Integer key numbered automatically (1, 2, 3...); PRIMARY KEY makes it unique2 id INT AUTO_INCREMENT PRIMARY KEY, -- Text up to 100 characters; NOT NULL makes it required3 name VARCHAR(100) NOT NULL, -- Exact decimal with 10 digits, 2 after the point; 0.00 if not given4 price DECIMAL(10,2) DEFAULT 0.00, -- Optional text up to 50 characters (NULL allowed)5 category VARCHAR(50), -- Filled with the insert time when no value is given6 created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP7);Output
Query OK, 0 rows affected
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this SQL code and how often they appear.
,× 5(× 4)× 4_× 3;× 1.× 1