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;

相关推荐
CodeStats25 分钟前
MySQL与Oracle数据类型底层设计原理对比(下)
数据库·mysql·oracle
疯狂打码的少年31 分钟前
【数据库技术】SQL高级查询(分组/排序/聚合函数)
java·数据库·笔记·sql
IvorySQL35 分钟前
PostgreSQL 日报|备用服务器 FSM 数据不一致(9 月 2 日)
服务器·数据库·postgresql
zcmodeltech1 小时前
风力发电沙盘模型控制系统设计与灯光联动实现方案——基于STM32与Modbus RTU,服务范围覆盖全国的多场景风力发电沙盘模型定制
网络·数据库·stm32·单片机·嵌入式硬件·能源
程序员黎剑1 小时前
MySQL-JOIN优化-NLJ与BNL的区别与实战
数据库·mysql
Java小白笔记1 小时前
MyBatis XML Mapper 标签与 CRUD 原理实战
xml·数据库·mybatis
JavaPub-rodert2 小时前
一个后台系统如何同时支持 MySQL、PostgreSQL、SQLite、SQL Server?从 ShiyuAdmin 的 GORM 多数据库适配说起
数据库·mysql·postgresql
小翰生信2 小时前
转录组下游分析全流程:DESeq2 差异分析、GO/KEGG 富集与 GSEA 实战
数据库·矩阵·golang
2603_966437262 小时前
拷贝中断文件丢失,电脑资料抢救实操方案
数据库·电脑