时间:2021-07-01 10:21:17 帮助过:30人阅读
语言书写规范问题:
查询创建的数据库:
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