Created
July 14, 2022 03:28
-
-
Save ManiruzzamanAkash/552b45e585971a572b5be1dd38d6765d to your computer and use it in GitHub Desktop.
MySQL-Keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create Primary Key | |
CREATE TABLE primary_test( | |
ID int PRIMARY KEY | |
); | |
-- Create Primary Key Multiple | |
CREATE TABLE primary_test( | |
ID INT NOT NULL, | |
EMAIL VARCHAR(50) NOT NULL, | |
PRIMARY KEY(ID, EMAIL) | |
); | |
-- Create Primary KEY | |
ALTER TABLE education | |
ADD PRIMARY KEY (employee_id); | |
-- Create Foreign KEY | |
ALTER TABLE education | |
ADD FOREIGN KEY | |
(employee_id) REFERENCES employee (id); | |
-- Create Unique key | |
CREATE TABLE primary_test3( | |
ID INT NOT NULL, | |
EMAIL VARCHAR(50) NOT NULL UNIQUE, | |
PRIMARY KEY(ID) | |
); | |
-- Create Index | |
ALTER TABLE employee | |
ADD INDEX (salary); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment