数据可名称可以为【bei】,字符集【utf8】,排序规则【utf8_general_ci】。
1、
建表语句——DDLCREATE TABLE `bei` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
`creatDate` 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=1 DEFAULT CHARSET=utf8;
2、插入语句——DML
INSERT INTO bei VALUES(
0,'2024-02-03 10:00:00','金背','10086','215652316',21,'男','墨西哥金背'
);
INSERT INTO bei VALUES(
0,'2020-02-13 10:00:00','蔡徐坤','12306','12315615641',27,'男','鸡你太美'
);
INSERT INTO bei VALUES(
0,'2023-06-07 12:00:00','李佳乐','030303','541563152',21,'男','二后生'
);
INSERT INTO bei VALUES(
0,'2023-07-08 12:00:00','石小姐','11034','156152656',20,'女','公主'
);
INSERT INTO bei(userName,age,introduce)VALUES
('蔡虚鲲',22,'鸡,篮球')
3 、基础查询语句——DQL
SELECT * FROM bei;
select userName as '姓名',age 年龄 ,sex '性别',introduce,'简介'
from bei
where pwd is not null;
select distinct sex '性别类型'from bei;
select userName as '姓名', 年龄 ,sex '性别' ,introduce '简介' from student ORDER BY age
desc;
select * from bei LIMIT 2;
select *from bei limit 4,2;
标签:语句,COMMENT,00,bei,DEFAULT,练习,DML,VALUES,NULL
From: https://blog.csdn.net/2301_81723241/article/details/137013282