Category: MySQL

MySQL Rename column

MySQL Rename column Rename MySQL column using alter table syntax and change keyword. MySQL Rename column syntax ALTER TABLE table_name CHANGE OLD_column_name new_column_name; Rename column example ALTER TABLE `books` CHANGE `stock` `in_stock` VARCHAR(2); Output table `books` altered....

MySQL Drop column

MySQL Drop column Drop column from MySQL table using alter table syntax. MySQL Drop column syntax ALTER TABLE table_name DROP COLUMN column_name; Drop column example ALTER TABLE `books` DROP COLUMN `stock`; Output table `books` altered....

MySQL Add column

MySQL Add column Add column to MySQL table using alter syntax. MySQL Add column syntax ALTER TABLE table_name ADD COLUMN column_name datatype; Add column example ALTER TABLE `books` ADD COLUMN `stock` VARCHAR(2); Output table `books` altered....

MySQL Drop table

MySQL Drop table MySQL Drop table syntax and examples. MySQL Drop table syntax DROP TABLE IF EXISTS table_name; DROP TABLE table_name; Drop table if exists example DROP TABLE IF EXISTS test2; Output table IF dropped. Drop table example DROP TABLE test3;...

MySQL Create table

MySQL Create table MySQL Create table syntax and examples. MySQL Create table syntax CREATE TABLE table_name (column_name column_data_type) ; Create an empty table based on the definition of another table CREATE TABLE new_table_name LIKE parent_table_name; Create a table using select statement...