设为首页 加入收藏

TOP

MySQL数据库day20190922(二)
2019-09-23 11:15:26 】 浏览:54
Tags:MySQL 数据库 day20190922
tudentname as 学生姓名,sex 性别 ,phone 联系方式 from student s
where studentname like '_李_';

5.根据指定学号(1011,1012,1013,1033)查询学生信息

5.1.between ... and :查询连续区号
select studentno,studentname as 学生姓名,sex 性别 ,phone 联系方式 from student s
where studentno between 1011 and 1013;

5.2. or
select studentno,studentname as 学生姓名,sex 性别 ,phone 联系方式 from student s
where studentno = 1011 or studentno = 1012 or studentno = 1013 or studentno = 1033;

5.3. in
select studentno,studentname as 学生姓名,sex 性别 ,phone 联系方式 from student s
where studentno in(1011,1012,1013,1033);

# 添加测试数据
insert into student(studentno,studentname,sex,gradeId,phone,address,email,indentityCard,loginpwd,borndate)
values(1031,'王李','男',1,'13500000001','北京海淀区中关村大街1号','guojing@bdqn.cn','450323198612111021','222',now()),
(1032,'文李才','男',4,'13500000012','河南洛阳号','liwencai@bdqn.cn','450323198112311021','123',now()),
(1033,'李梅','女',3,'13500000025','上海卢湾区','limei@bdqn.cn','450323198612311021','223',now());

三.将数据库中的数据导出(数据备份)
1.dos命令备份:
mysqldump -uroot -p 数据库 [指定数据表] >指定磁盘路径地址:/xxx.sql文件

2.dos命令导入数据
source 导入的sql文件地址


四、##创建年级表
create table if not exists grade(
gid int(11) primary key auto_increment not null comment '主键,年级编号',
gname varchar(32) comment '年级名称'
);

create table if not exists student(
studentno int(4) primary key auto_increment not null comment '学号',
loginpwd varchar(20) not null comment '密码',
studentname varchar(20) not null comment '学生姓名',
sex char(2) default '男' not null comment '性别',
gradeId int(11) not null comment '年级编号',
phone varchar(50) comment '联系方式,允许为空',
address varchar(255) comment '地址,允许为空',
borndate datetime not null comment '出生日期',
email varchar(50) comment '邮箱账号,允许为空',
indentityCard varchar(18) unique comment '身份证号',
foreign key(gradeId) references grade(gid)
)comment='学生表';

注: 建库、建表 、再操作数据;
在dos命令添加中文数据,出现中文添加失败, 设置命令: set names gbk;



 

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Python操作MongoDB查询时处理Obje.. 下一篇MySQL 排错-解决MySQL非聚合列未..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目