1.建表语句----DDL
CREATE TABLE `月光` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`createdate` datetime DEFAULT NULL,
`username` varchar(20) DEFAULT NULL,
`pwd` varchar(36) DEFAULT NULL,
`phone` varchar(11) DEFAULT NULL,
`age` tinyint(3) DEFAULT NULL,
`sex` char(2) DEFAULT '男',
`introduce` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
2.插入语句----SQL
INSERT into 月光 VALUES(0,'2024-02-18 00:00:00','江若琳','1314520','15931055753',19,'女','宇宙无敌超级美女')
INSERT into 月光 VALUES(1,'2024-03-25 00:00:00','高乙磊','1314521','15931055756',19,'男','查无此人')
3.基础查询语句---DQL
SELECT * FROM 月光;
SELECT username as '姓名',age,sex,'性别',introduce'简介'
FROM 月光
where pwd is not null;
SELECT DISTINCT sex '性别类型' FROM 月光;
SELECT username as '姓名',age,sex,'性别',introduce'简介' FROM 月光 ORDER BY age desc;
SELECT *from 月光 LIMIT 2
标签:00,varchar,DEFAULT,练习,月光,日常,SQL,NULL,SELECT
From: https://blog.csdn.net/z15931055753/article/details/137012998