当前位置:Gxlcms > mysql > mysql建数据库建表_MySQL

mysql建数据库建表_MySQL

时间:2021-07-01 10:21:17 帮助过:11人阅读

创建数据库:create database td character set =utf8;use database td;//在数据库td中创建表
create table tb_student (
Student_ID int auto_increment primary key,
Student_Name varchar(20),
Sex char(1),
Birthday varchar(10)
) engine=innodb default character set =utf8 auto_increment =100;//指定存储引擎和字符集 create table tb_subject (
Subject_ID int auto_increment primary key,
Subject_Name varchar(50)
) engine=innodb default character set =utf8;

create table tb_score (
ID int auto_increment primary key,
Student_ID int,
Subject_ID int,
Score decimal(10,2),
foreign key (Student_ID) references tb_student(Student_ID),//外键
foreign key (Subject_ID) references tb_subject(Subject_ID)
) engine=innodb default character set =utf8;

人气教程排行