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;

相关推荐
zhangjw345 小时前
2-4 集合运算 union /union all /intersect/except
数据库·postgresql
Decay__6 小时前
PostgreSQL DBA 日常运维手册 —— 会话、锁阻塞、慢查询、膨胀与每日巡检
运维·数据库·sql·postgresql
FungLeo6 小时前
FengCMS ·PHP+MySQL 升级实录· 设置发布与模板缓存:数据库与配置文件如何避免旧表单覆盖
数据库·mysql·php·工程实践·fengcms
千寻技术帮6 小时前
微信小程序+Spring Boot 烘焙商城系统(附完整源码+数据库+部署文档)50053
数据库·spring boot·微信小程序·烘焙商城
TiDB 社区干货传送门7 小时前
当向量走向百亿规模:平凯数据库对下一代分布式向量索引的探索
数据库·分布式
斯维赤7 小时前
SELECT * 为什么是覆盖索引的天敌?
java·后端·mysql
FungLeo7 小时前
FengCMS · PHP+MySQL 升级实录· 编译缓存并发:锁定产物执行、避免重复发布与三类缓存清理
mysql·缓存·php·并发·fengcms
倔强的石头_7 小时前
MySQL兼容性实测:用户变量、多表更新这些“习惯”能不能带过来
数据库
Flynn Liang7 小时前
RAG 检索性能提升:Redis 向量 + 全文 + 元数据过滤的混合检索实战
数据库·人工智能·redis·缓存·rag·ai agent·智能体
kiwixing7 小时前
GaussDB|几台机器、哪种协议:高可用部署形态与副本协议选型
数据库·sql·database·gaussdb