Home >Database >Mysql Tutorial >mysql 建数据库 建表_MySQL
创建数据库:create database td character set =utf8;use database td;//在数据库td中创建表
create table tb_student (<br>Student_ID int auto_increment primary key, <br>Student_Name varchar(20), <br>Sex char(1), <br>Birthday varchar(10)<br>) engine=innodb default character set =utf8 auto_increment =100;//指定存储引擎和字符集 create table tb_subject (<br>Subject_ID int auto_increment primary key, <br>Subject_Name varchar(50)<br>) engine=innodb default character set =utf8;<br><br>create table tb_score (<br>ID int auto_increment primary key,<br>Student_ID int,<br>Subject_ID int,<br>Score decimal(10,2),<br>foreign key (Student_ID) references tb_student(Student_ID),//外键<br>foreign key (Subject_ID) references tb_subject(Subject_ID)<br>) engine=innodb default character set =utf8;