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;

相关推荐
lambo mercy5 分钟前
Day3:结构化输出
java·数据库·oracle
派小心.17 分钟前
小程序分享链路中来源参数的传递校验
大数据·前端·数据库·人工智能·小程序·数据分析
Είναι η κοπέλα19 分钟前
向量数据库与嵌入模型:Chroma/FAISS/Milvus 选型
数据库·milvus·faiss
IvorySQL1 小时前
从轮询到等待——PostgreSQL WAIT FOR LSN 特性深度解析
数据库·postgresql
Sayai1 小时前
DataX 离线数据同步实战:Elasticsearch 数据批量导出 MySQL(作业配置、并发调优与定时同步平台化设计)
大数据·mysql·elasticsearch·datax·数据同步
OceanBase数据库官方博客1 小时前
被 VLDB 2027接收OceanBase 最新论文让数据库基(技术解析与实践)
数据库·人工智能·oceanbase
颜酱2 小时前
一栋商业大厦,讲清 InnoDB 的表空间、段、区和页
后端·mysql
创邻科技2 小时前
国产图数据库刷新 LDBC 世界纪录:创邻科技 Galaxybase 在 SF100、SF300、SF1000 测试中全面领先”
数据库·科技
GreatSQL社区2 小时前
主从复制SQL线程中断——字符集砸出的坑
java·数据库·算法
XLYcmy2 小时前
AI 赋能后中文与英文数据库对比分析报告 上
数据库·ai·llm·prompt·检索·wos·cnki