MySQL Drop index Drop index from MySQL table using alter table syntax. MySQL Drop index syntax ALTER TABLE table_name DROP INDEX index_name; Drop index example ALTER TABLE `books` DROP INDEX idx_product_id; Output table `books` altered....
MySQL Add index Add index on MySQL table using alter table syntax. MySQL Add index syntax ALTER TABLE table_name ADD INDEX index_name(column_name); Add index example ALTER TABLE `books` ADD INDEX idx_product_id (product_id); Output table `books` altered....
MySQL Drop foreign key Drop foreign key from MySQL table using alter table syntax. MySQL Drop foreign key syntax ALTER TABLE table_name DROP FOREIGN KEY foreign_key_name; Drop foreign key example ALTER TABLE `books` DROP FOREIGN KEY fk_product_id; ALTER TABLE `books` DROP...
MySQL Add primary key Add primary key to MySQL table using alter table syntax and primary key keyword. MySQL Add primary key syntax ALTER TABLE table_name ADD PRIMARY KEY (column_name); Add primary key example ALTER TABLE `books` ADD PRIMARY KEY (id);...