Skip to content

Instantly share code, notes, and snippets.

@ManiruzzamanAkash
Created July 14, 2022 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ManiruzzamanAkash/552b45e585971a572b5be1dd38d6765d to your computer and use it in GitHub Desktop.
Save ManiruzzamanAkash/552b45e585971a572b5be1dd38d6765d to your computer and use it in GitHub Desktop.
MySQL-Keys
-- 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