MySQL日常语句练习

前言

数据库名可以为schooldb,字符集utf8,排序规律【utf8_general_ci】

1,建表语序——DDL

​
CREATE TABLE `schooldb` (
  `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=7 DEFAULT CHARSET=utf8;

​

2,输入语句——DML

INSERT INTO schooldb VALUES(0,'2024-02-22  10:00:00','刘德华','123454','12345678909',62,'男','男神');
INSERT INTO schooldb VALUES(0,'2024-02-22  10:00:00','刘青云','123456','13023455432',56,'男','好演员');
INSERT INTO schooldb VALUES(0,'2024-02-22  10:00:00','周星驰','123432','13423456789',61,'男','重视爱情');
INSERT INTO schooldb VALUES(0,'2024-02-22  10:00:00','刘亦菲','123432','13423456689',18,'女','神仙姐姐');
INSERT INTO schooldb VALUES(0,'2024-02-22  10:00:00','成龙','123432','13423411789',61,'男','功夫之星');

3,查询语句——DQL

SELECT * FROM `schooldb`where userName like  '刘%';
SELECT * FROM `schooldb`where pwd is null;
SELECT * FROM `schooldb`where pwd is not null;
SELECT * FROM `schooldb`where age between 30 and 40;
SELECT * FROM `schooldb`where createDate between '2024-02-21 00:00:00'and'2024-02-23 00:00:00';
SELECT * FROM `schooldb`where userName in ('刘德华','刘亦菲');
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值