mysql create table primary key code example
Example 1: alter table add foreign key mysql
ALTER TABLE orders
ADD
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
Example 2: create table in mysql
CREATE TABLE user (
userId INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(100),
password VARCHAR(100)
) ENGINE=InnoDB;
Example 3: mysql change primary key
ALTER TABLE tableName MODIFY COLUMN id INT;
ALTER TABLE tableName DROP PRIMARY KEY;
ALTER TABLE tableName ADD PRIMARY KEY (new_id);
ALTER TABLE tableName MODIFY COLUMN new_id INT AUTO_INCREMENT;
Example 4: create table mysql query
create table tutorials_tbl(
tutorial_id INT NOT NULL AUTO_INCREMENT,
tutorial_title VARCHAR(100) NOT NULL,
tutorial_author VARCHAR(40) NOT NULL,
submission_date DATE,
PRIMARY KEY ( tutorial_id )
);
Example 5: mysql create table
CREATE TABLE nom_de_la_table
(
colonne1 type_donnees,
colonne2 type_donnees,
colonne3 type_donnees,
colonne4 type_donnees
)