What is Primary Key, Create Primary Key , Alter Primary Key and Drop Primary Key | MySQL Tutorial

preview_player
Показать описание
Primary key in MySQL can be single or multiple fields that defines
unique record. A table can have only single primary key and non of the columns
which are part of Primary key can have null value.

Topics covered in this video
What is Primary Key in MySQL
How to Create Primary Key on single Column
How to create Primary key with multiple columns
How to add Primary key on existing table
How to drop Primary Key

link to scripts used in MySQL Developer Tutorial / MariaDB developer Tutorial

MySQL Tutorial for Beginners
MySQL Development Tutorial
MySQL Tutorial for developers
MySQL Development Training
MySQL training for developers
MySQL Workbench Tutorial
MySQL DBA Certification Training
MySQL DBA Tutorial Step by Step
MySQL DBA Training online free
MySQL Real Time DBA Tutorial
MySQL Administration Course step by Step
MySQL Tools for Development and Admin
Рекомендации по теме
Комментарии
Автор

Great video about the Primary key, Thanks a lot!!!

czvinayak
Автор

sir, I have created a table to practice 'adding' and 'removing' primary key using constraints in MySQL.



syntax: create table test1 (id_no int, name varchar(25));



now, i wanted to add a primarykey to the existing table, and i had used a constraint so that i could remove primary key from column in future.



syntax: alter table test1 add constraint pk_id primary key(id_no);



when i tried to drop constraint



syntax: alter table test1 drop constraint pk_id;



it says:

ERROR 3940 (HY000): Constraint 'pk_id' does not exist.


if i exicute this syntax it works
alter table test1 drop primary key;

its not registering primarykey constraint...
whats the problem,
is there any way to add primary key constraint.

kirangtkl