MySQL部分语句

create table student1(

id int primary key,

name varchar(20),

city varchar(18),

gender char(1),

score int

);

insert into student1 values(1,'张三','郑州','男',98),(2,'李四','上海','男',99),(3,'小红','洛阳','女',95),(4,'小李','开封','男',90);

insert into student1 VALUES (5,'钱七','上海','男',95),(6,'孙八','上海','女',58);

select name,score from student1 where city='郑州';

select *from student1 where score>=80 ORDER BY score desc;

select count(*)from student1;

select city, avg(score) as 平均分 from student1 group by city HAVING avg(score)>75;

select gender, max(score) as 最高分 from student1 GROUP BY gender;

select name from student1 where name like '张%'or name like '李%';

delete from student where id=18;

DELETE from student;

drop table student;

alter table students add age int;

show databases;

use mydb;

select database();

show tables;

desc student1;

select*FROM student1;

show create database mydb;

alter table students add ip varchar(20);

alter table student1 add address varchar(15);

alter table student1 change address addresses varchar(20);

alter table student1 change addresses address varchar(50);

alter table student1 drop address;

alter table students MODIFY age int;

alter table student1 modify gender varchar(18);

alter table student1 rename student;

alter table students rename student1;

delete from student where score=99;

alter table student add address varchar(20);

UPDATE student set address ='郑州';

update student set address='洛阳' where name='张三';

create table a(

id int PRIMARY KEY not null,

name varchar(20) unique,

address varchar(18) DEFAULT('南阳')

);

insert into a (name,id) values ('张三',18),

('李四',19);

insert into a(name,id) VALUES('张四',20);

drop table a;

相关推荐
小白男神1 天前
MySQL进阶学习四(存储过程、游标、触发器)
mysql
这个DBA有点耶1 天前
MVCC深入:Read View、版本链与快照读——InnoDB并发控制的内核
数据库·mysql·架构
DBA_G1 天前
从地面到云霄:GBase数据库在民航三大场景的落地实践
数据库
自由能燃气设备1 天前
商用全预混低氮冷凝锅炉免费方案vs付费方案对比+选型避坑指南
大数据·数据库·人工智能
科创致远1 天前
科创致远 ESOP 系统核心效能与实战价值展示
大数据·数据库·人工智能·精益工程
kybs19911 天前
全球灾害数据分析可视化 毕业设计-附源码66794
vue.js·spring boot·mysql·安全·django·c#·asp.net
2601_962218611 天前
万象生鲜系统称重自动多退少补算法解决生鲜非标品痛点
大数据·数据库·人工智能·python·算法
程序猿_极客1 天前
【免费】分享一套优质的基于SSM的校园失物招领系统的设计与实现,源码+文档+视频详解(讲解)
java·mysql·ssm·课程设计·失物招领系统
张洛闻Eren1 天前
k8s云原生【第十课】:水平 Pod 自动扩缩容
运维·数据库·云原生·kubernetes·github
于平安1 天前
MySQL-触发器
数据库·mysql