前言
数据库名称可以为【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` varchar(2) DEFAULT NULL COMMENT '性别',
`introduce` varchar(255) DEFAULT NULL COMMENT '简介',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
2.插入语句——DML
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','刘德华','123456','15632145678',62,'男','永远的男神,爱你一万年。');
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','李青云','123456','15632147894',65,'男','真正的演员,好角色用心演绎。');
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','周星驰','123456','15632147895',61,'男','所以的电影都没有对爱情有过轻视。');
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','张翰','123456','15632147896',32,'男','一起坐死在流星雨下。');
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','王祖贤','123456','15632147894',27,'女','你再美你能比过王祖贤吗?');
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','','123456','15632147894',65,'男','真正的演员,好角色用心演绎。');
INSERT INTO student (userName,age,introduce)VALUES('刘亦菲',37,'神仙姐姐');
3.基础查询语句——DKL
select * from student;
select userName,age,introduce
from student
where pwd is not null;
select distinct sex '性别类型' from student;
select userName as '姓名',age '年龄',introduce'简介'from student order by age desc;
select*from student limit 2;
select*from student limit 4,2
标签:语句,COMMENT,00,manba,DEFAULT,练习,VALUES,student,NULL
From: https://blog.csdn.net/xxtsss/article/details/137013001