ALTER TABLE in SQL
Level 5216 keystrokes
ALTER TABLE changes a table's structure; one statement can add columns, add an index and modify a column.
SQL code
-- Change the structure of products; the changes are separated by commas1ALTER TABLE products -- New integer column; existing rows get 02 ADD COLUMN stock INT DEFAULT 0, -- New timestamp column, set to the current time on insert3 ADD COLUMN updated_at TIMESTAMP4 DEFAULT CURRENT_TIMESTAMP -- ...and refreshed automatically whenever the row is updated5 ON UPDATE CURRENT_TIMESTAMP, -- Index on category to speed up searches and sorts by category6 ADD INDEX idx_category (category), -- MODIFY replaces the whole column definition: now up to 200 characters, still required7 MODIFY COLUMN name VARCHAR(200) NOT NULL;Output
Query OK, 0 rows affected Records: 0 Duplicates: 0 Warnings: 0
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.
_× 4,× 3(× 2)× 2;× 1