语言书写规范问题:
- 括号要分行
- 最后一行不需要逗号
- 外键时FK_Stuid1值需要改变,即不能重复
- 先创建不含外键的数据表,在创建含有外键的数据表
查询创建的数据库:
show databases;
查询表结构:
use school; desc tb_student;

增加数据信息:
#在学生姓名之后添加电话字段 use school; alter table tb_student add `phone` varchar(15) after `SName`;

#为表tb_student添加字段classid,并设置为外键。 use school; alter table tb_student add deptId int(11) not null; alter table tb_student add constraint `FK_dept_student` foreign key(`deptId`) references tb_dept(`id`);

创建数据记录表:
use school; insert into tb_dept(id,Local,Dnum) values (null,‘cy‘,‘1‘), (null,‘qy‘,‘1‘), (null,‘zy‘,‘1‘);
use school;
insert into tb_dept(id,Local,Dnum) values
(null,‘cy‘,‘1‘),
(null,‘ry‘,‘2‘),
(null,‘ty‘,‘3‘);
查询数据库:
SELECT Local,Dnum FROM tb_dept ORDER BY Dnum;

数据库MySQL的创建
标签:结构 分享 creat 建表 ase uid gen into logs