前言
数据库名称可以为{ schoolDB },字符集【utf8】,排列规则【utf8_general_ci】。
1、建表语句——DDL
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
`createDate` datetime DEFAULT NULL COMMENT '创建时间',
`userName` varchar(20) DEFAULT NULL COMMENT '用户名',
`pwd` varchar(36) DEFAULT NULL COMMENT '密码',
`phone` varchar(11) DEFAULT NULL COMMENT '手机号',
`age` tinyint(3) DEFAULT NULL COMMENT '年龄',
`sex` char(2) DEFAULT NULL COMMENT '性别',
`introduce` varchar(255) DEFAULT NULL COMMENT '简介',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
2、插入语句——DML
insert into student values(0,'2020-10-20','流的花','123456','15615615611',34,'男','我爱你' );
insert into student values(0,'2023-8-12','我不想','123456','15615615613',43,'男','说' );
insert into student values(0,'2020-08-13','搞狙击','126456','15615623611',12,'男','秒了' );
insert into student values(0,'2020-10-20','白菊良','123456','13615615611',99,'女','bzd' );
insert into student values(0,'2020-03-19','李于洋','126456','15615623611',12,'男','我是狗' );
insert into student values(0,'2020-10-10','李宇杨','222456','13615615611',99,'女','我也是' );
select * from
3、基础查询语句——DQL
#1、基础查询
select * from student;
#2、分列匿名以及筛选数据查讯
select userName as '姓名',age 年龄,sex '性别',introduce '简介'
from student
where pwd is not null;
#3、去重查询
select distinct sex '性别类型' from student;
#4、排序查询
select userName as '姓名',age 年龄,sex'性别',introduce'简介' from student ORDER BY age desc;
#5、分页查询-limit这是个重载函数
select * from student LIMIT 2;
#2个参数,参数1;从n条开始查询,n的起始坐标为0条。参数2;查询条数
select * from student limit 4,2;
标签:语句,COMMENT,insert,DEFAULT,练习,DML,student,NULL,select
From: https://blog.csdn.net/2301_80391641/article/details/137013019