首页 > 数据库 >MySQL学习必备

MySQL学习必备

时间:2024-03-25 12:04:49浏览次数:25  
标签:25 00 DEFAULT 必备 学习 123 student MySQL NULL

1.学生表DDL

CREATE TABLE `student` (
  `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 NULL,
  `inteoduce` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

2.插入学生信息DML

INSERT INTO student VALUES(0,'2024-02-25 10:00:00','赵灵儿','123',
'15612345678',16,'女','逍遥哥哥,你终于找到我了' );
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','王语嫣','123',
'15612345678',17,'女','慕容复,我与你不共戴天' );
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','龙姑娘','123',
'15612345678',22,'女','我想过过过儿过过的日子' );
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','杨过','123',
'15612345678',18,'男','一遇杨过误终身' );
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','杨逍','123',
'15612345678',27,'男','杨过与程英之子' );
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','黄蓉','123',
'15612345678',18,'女','我是黄蓉' );
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','白羊','123',
'15612345678',21,'男','我要开始说谎了' );

实际效果:

3.基础查询测试DQL

# 基础查询
SELECT * FROM `student`;
#筛选列(匿名)与筛选数据行
select userName as 姓名,age'年龄',sex'性别',intouduce'简介'
from student
where pwd is not null;
#分页 limit有两个重载函数常用
#一个参数为显示条数
#一个参数为从那条开始查询(下标从0开始计算),零一参数为显示条数
select * from student limit 3,2;#从4(0-3)开始查询2条。
#排序,order by根据数值类型进行排序会比较准确
select * from student order by age desc limit 3;
#去重语句distinct
select * distinct sex '性别类型' from student;

标签:25,00,DEFAULT,必备,学习,123,student,MySQL,NULL
From: https://blog.csdn.net/2301_82249066/article/details/137009004

相关文章

  • MySQL学习必备SQL_DDL_DML_DQL
    MySQL创建数据库需要自行创建,数据库名称可以为【schoolDB】,字符集【utf8】,排序规则【utf8_general_ci】1、学生表DDLCREATETABLE`student`(`id`int(11)NOTNULLAUTO_INCREMENTCOMMENT'学号',`createDate`datetimeDEFAULTNULL,`userName`varchar(20)DEF......
  • MySQL学习必备SQL_DDL_DML+DQL
    MySQL创建数据库需要自行创建,数据库名称可以为【schoolDb】,字符集【utf8】,【utf8_general_ci】1.学生表CREATETABLE`student`(`id`int(11)NOTNULLAUTO_INCREMENTCOMMENT'学号',`createDate`datetimeDEFAULTNULL,`userName`varchar(20)DEFAULTNULL,......
  • My QPL学习
    1、学生表DDLCREATETABLE`student`(`id`int(11)NOTNULLAUTO_INCREMENTCOMMENT'学号',`createDate`datetimeDEFAULTNULL,`userName`varchar(20)DEFAULTNULL,`pwd`varchar(36)DEFAULTNULL,`phone`varchar(11)DEFAULTNULL,`age`tin......
  • MySQL学习必备SQL_DDL_DML_DQL
    mysql创建1、学生表CREATETABLE`student`(`id`int(11)NOTNULLAUTO_INCREMENTCOMMENT'学号',`createdate`datetimeDEFAULTNULL,`username`varchar(20)DEFAULTNULL,`pwd`varchar(36)DEFAULTNULL,`phone`varchar(11)DEFAULTNULL,`age......
  • MySQL学习必备SQL-DDL-DQL
    MySQL创建数据库需要自行创建,1、学生表DDLCREATETABLE`student`(`id`int(11)NOTNULLAUTO_INCREMENTCOMMENT'学号',`createDate`datetimeDEFAULTNULLCOMMENT'开始日期',`userName`varchar(20)DEFAULTNULLCOMMENT'用户名',`pwd`varcha......
  • MySQL
    1学生表DDLCREATETABLE`student`(`id`int(11)NOTNULLAUTO_INCREMENT,`createdate`datetimeDEFAULTNULL,`username`varchar(20)DEFAULTNULL,`pwd`varchar(36)DEFAULTNULL,`phone`varchar(11)DEFAULTNULL,`age`tinyint(3)DEFAULTNULL,......
  • MySQL学习必备SQL_DDL_DML_DQL
    1.MySQL数据库创建(学生表)CREATETABLE`student`(`id`int(11)NOTNULLAUTO_INCREMENT,`createdate`datetimeDEFAULTNULL,`username`varchar(255)CHARACTERSETutf8DEFAULTNULL,`pwd`varchar(255)CHARACTERSETutf8DEFAULTNULL,`phone`varcha......
  • MySQL学习必备SQL DDL DML DQL
    1、学生表DDLCREATETABLE`aa`(`id`int(11)NOTNULLAUTO_INCREMENTCOMMENT'学号',`creaDate`datetimeDEFAULTNULL,`userName`varchar(20)DEFAULTNULL,`pwd`varchar(36)DEFAULTNULL,`phone`varchar(11)DEFAULTNULL,`age`tinyint(3)......
  • MySQL学习必备SQL_DDL_DML_DQL
    1、学生表DDLCREATETABLE`student`( `id`int(11)NOTNULLAUTO_INCREMENTCOMMENT'学号', `createDate`datetimeDEFAULTNULL, `userName`varchar(20)DEFAULTNULL, `pwd`varchar(36)DEFAULTNULL, `phone`varchar(11)DEFAULTNULL, `age`ti......
  • MySQL必备学习
    1.学生表CREATETABLE`student`(`id`int(11)NOTNULLAUTO_INCREMENT,`createDate`datetimeDEFAULTNULL,`userName`varchar(20)DEFAULTNULL,`pwd`varchar(36)DEFAULTNULL,`phone`varchar(11)DEFAULTNULL,`age`tinyint(3)DEFAULTNULL,......