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

MySQL 学习必备SQL_DDL_DML_DQL

时间:2024-03-25 12:32:39浏览次数:26  
标签:11 00 DEFAULT into DML 123 student DDL DQL

mySQL创建数据库需要自行创建,

数据库名称可以为【schoolDB】,字符集【utf8】,排列规则【utf8_general_ci】,2

1、学生表DDL

CREATE TABLE `student` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
  `creatDate` 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=1 DEFAULT CHARSET=utf8;

2、插入学生信息DML

insert into student values(0,'2024-02-24 10:00:00','赵灵儿','123','12312345678',11,'女','逍遥哥哥,你终于找到我了。');
insert into student values(0,'2024-02-24 10:00:00','王语嫣','123','12312345678',11,'女','我和你不共戴天。');
insert into student values(0,'2024-02-24 10:00:00','龙姑娘','123','12312345678',11,'女','过儿。');
insert into student values(0,'2024-02-24 10:00:00','李莲花','123','12312345678',11,'男','武功很厉害。');
insert into student values(0,'2024-02-24 10:00:00','杨过','123','12312345678',11,'男','一遇杨过误终身。');
insert into student values(0,'2024-02-24 10:00:00','黄衣女子','123','12312345678',11,'女','杨过与龙姑娘的大女儿。');
insert into student values(0,'2024-02-24 10:00:00','杨逍','123','12312345678',11,'女','杨过跟程英的大儿子。');

3、基础查询测试DQL

select * from student;
select userName as 姓名,age '年龄',sex '性别',introduce '简介'
from student 
where pwd is not null;
select * from student limit 3,2;
select * from student order by age desc limit 3;
select distinct sex '性别类型' from student;

标签:11,00,DEFAULT,into,DML,123,student,DDL,DQL
From: https://blog.csdn.net/H18703199283/article/details/137009044

相关文章

  • MySQL学习必备SQL_DDL_DML_DQL
    MySQL创建数据库需要自行创建,数据库名称可以为【schoolDB】,字符集【utf-8】,排序规则【utf8_general_ci】。1、学习表DDLCREATETABLE`student`(`id`int(11)NOTNULLAUTO_INCREMENT,`createDate`datetimeDEFAULTNULL,`userName`varchar(20)DEFAULTNULL,......
  • 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,......
  • 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学习必备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 SQL_DDL_DML_DQL
    1.学生表DDL字符集[utf8]CREATETABLE`student`( `id`int(11)NOTNULLAUTO_INCREMENTCOMMENT'学号', `createDate`datetimeDEFAULTNULLCOMMENT'日期', `userName`varchar(20)DEFAULTNULLCOMMENT'姓名', `pwd`varchar(36)DEFAU......
  • 3.MySQL数据库的基本操作-DQL 基本操作
    MySQL数据库的基本操作-DQL基本操作查询select语法格式select[all|distinct]<目标列的表达式1>[别名],<目标列的表达式2>[别名]...from<表名或视图名>[别名],<表名或视图名>[别名]...[where<条件表达式>][groupby<列名>[having<条件表达式>]][o......