1、设计一张图书表,包含以下字段:图书名称,图书作者、图书价格、图书分类
drop table if exists booklist;
create table booklist(
book_name varchar(50),
book_author varchar(30),
book_price decimal(4,2),
book_category varchar(20)
);
2、设计一张老师表,包含以下字段:姓名、年龄、身高、体重、性别、学历、生日、身份证号
drop table if exists teacher;
create table teacher(
name varchar(20),
age int,
height double,
weight double,
sex varchar(5),
degree varchar(20),
birthday timestamp,
id_number varchar(18)
);
3、设计一张商品表,包含以下字段:商品名称、商品价格、商品库存、商品描述
drop table if exist product;
create table product(
name varchar(20),
price decimal(11,2),
stock int,
description varchar(50));
4、在以上创建的商品表中插入一条数据:名称为“学生书包”、价格18.91、库存101、描述为空
insert into product values('学生书包',18.91,101,null);
insert into product(name,price,stock) values(('学生书包',18.91,101);
5、在图书表中新增一条记录:Java核心技术、作者“Cay S. Horstman”,价格56.43,分类为“计算机技术”
insert into booklist values('Java核心技术','cay s.horstman',56.43,'计算机技术');
6、student学生表中,字段有姓名name,年龄age,要求查询姓张,并且年龄在18到25岁之间的学生
select * from student where like '张%' and age between 18 and 25;
7、查询article文章表中,发表日期create_date在2019年1月1日上午10点30分至2019年11月10日下午4点2分的文章
select * from artical where create_date between '2019-01-01 10:30:00' and ‘2019-11-10 16:02:00';
8、查询article文章表中,文章标题title为空,或者满足发表日期create_date在2019年1月1日之后
select * from artical where title is null or create_date > '2019-01-01 00:00:00';
select * from artical where title <=> null or create_date > '2019-01-01 00:00:00';