CREATE DATABASE index
;
SHOW DATABASES;
DROP DATABASE index;
SHOW ENGINES \G
SHOW VARIABLES LIKE
‘
have%
’
;
SHOW VARIABLES LIKE
‘
storage_engine
’
;
CREATE DATABASE example;
CREATE TABLE example0(
Id INT,
Name VARCHAR(20),
Sex BOOLEAN
);
SHOW TABLES;
DESCRIBE example0;
CREATE TABLE example1(
Stu_id INT PRIMARY KEY
,
Stu_name VARCHAR(20),
Stu_sex BOOLEAN
);
CREATE TABLE example2(
Stu_id INT,
Course_id INT,
Grade FLOAT,
PRIMARY KEY(stu_id,courage_id)
);
CREATE TABLE example3(
Id INT PRIMARY KEY
,
Stu_id INT,
Course_id INT,
CONSTRAINT c_fk FOREIGN KEY(stu_id,course_id) REFERENCES example2(stu_id,course_id)
);
DESCRIBE example3;
CREATE TABLE example4(
Id INT NOT NULL PRIMARY KEY
,
Name VARCHAR(20) NOT NULL,
Stu_id INT,
CONSTRAINT d_fk FOREIGH KEY(stu_id) REFERENCES example1(stu_id)
);