当前位置:网站首页>Simple command of mysql
Simple command of mysql
2022-07-31 05:32:00 【The flowers are blooming in the south of the city^】
Database words
create create
database database
drop delete
show show
use use
delete delete
describe describe desc
select query
varchar stringtype
char string type
date date
time time
datetime time dateStatement
createa database; library name; create library
drop database; library name; delete library
show databases; view all libraries
use library name; use library
desc table name;Query table structure
desc table name header;query a structure
Create table basic structure
create table table name (
;Modify structure
1. Add fields add
Add one field at a time
Alter table table name add field name field type;
Add multiple fields at a time
Alter table table name add field name fieldtype, add field name field type,...;
2 delete fields drop
delete one field at a time
alter table table name drop field name field type;
delete multiple fields at a time
alter table table name drop field name field type, drop field name field type,...;
3 Modify field type modify
Modify one field at a time
Alter table table name modify field name modify field type;
Modify multiple fields at a time
Alter table table name modify field nameModify field type, modify field name modify field type...;
4 Modify field name change
Modify one field name at a time
Alter table table name change Original field name modified field name Modified field type;
Modify multiple field names at a time
Alter table table name change original field name modified field name modified field type, change original field name modified field name modified field type...;
Deletion of data table
1 delete table
drop table table name;
2 modify table name
1) rename table original table name to new table name;
2) alter table original table name renameto new table name;
Data Insertion
1. Add one at a time
Insert into table name (column name 1, column name 2, column name 3) value (data 1, data 2, data 3);
2. Add at a timeMultiple
insert into table name (column name 1, column name 2, column name 3) value
(data 1, data 2, data 3),
(data 1, data 2, data 3),
(Data1,Data2,Data3),
(…);Query table content
Select * from table name;
Query single data
Select field from table name;
Query multiple data
select field name 1, field name 2, fieldname 3 from table name;
deduplication query
selest distinct field name from table name;
operator query
select field name + field name from table name;
conditional query result in 80The above
select name, score from table name where score>80;
set query
1 in the range of set query
select * from table name where field name in();
2Not in collection range query
Select * from table name where field name not in();
Range query
Select * from table name where field name between 70 and 90;
Null value query
select field name from table name where score is empty in null;
non-null value query
select field name from table name where score in not null;
multi-condition query
select * from table name whereGrade>80 and age>15;
Add primary key constraint
Alter table table name add primarg key (field name);
Delete self-increment constraint/primary key constraint
Alter table table name modify field name fieldtype;
alter table table name drop primarg key;
delete not-null constraint
alter table table name modify field name field type;
delete unique constraint
alter table table name modify field name fieldtype;
alter table table name drop index field name;
delete default constraint
alter table table name modify field name field type;
default defaultprimary key constraint primarg key
Auto Increment Constraint auto_increment
Foreign key constraints
foreign key (field name) references table name (field name);
delete foreign key
alter table table name drop foreign key name;Name the foreign key constyaint name
sort in descending order
select * from table name order by field desc;
ascending order
select * from table name order by field asc;Modify the fields of a single record
update table name set field name='modified name'where id=1;Modify fields of multiple records
Update table name set field name='modified name' … where id=serial number;Data deletion
delete a record
delete from table name where id=1;
delete multiple records
delete from table name where id=2 or id=3;
边栏推荐
- Information System Project Manager Core Test Site (55) Configuration Manager (CMO) Work
- MySQL优化之慢日志查询
- Centos7 install mysql5.7
- C语言如何分辨大小端
- 账号或密码多次输入错误,进行账号封禁
- 剑指offer基础版 ---- 第29天
- About the problems encountered by Xiaobai installing nodejs (npm WARN config global `--global`, `--local` are deprecated. Use `--location=glob)
- SQL行列转换
- Goodbye to the cumbersome Excel, mastering data analysis and processing technology depends on it
- mysql 的简单运用命令
猜你喜欢

MySQL(更新中)

MySQL transaction (transaction) (this is enough..)

Lock wait timeout exceeded解决方案

Quickly master concurrent programming --- the basics
【一起学Rust】Rust的Hello Rust详细解析

一文了解大厂的DDD领域驱动设计

Multiple table query of sql statement

MySQL8.0.26安装配置教程(windows 64位)

Tapdata 与 Apache Doris 完成兼容性互认证,共建新一代数据架构

MySQL8--Windows下使用压缩包安装的方法
随机推荐
What are the advantages and disadvantages of Unity shader forge and the built-in shader graph?
剑指offer专项突击版 ---第 5 天
Linux系统安装mysql(rpm方式安装)
C语言指针详解
关于LocalDateTime的全局返回时间带“T“的时间格式处理
质量小议12 -- 以测代评
运用flask框架发送短信验证码的流程及具体代码
ES source code API call link source code analysis
【MQ我可以讲一个小时】
Mysql——字符串函数
账号或密码多次输入错误,进行账号封禁
The interviewer asked me how to divide the database and the table?Fortunately, I summed up a set of eight-part essays
C语言如何分辨大小端
MySQL (updating)
MYSQL下载及安装完整教程
Workflow番外篇
[MQ I can speak for an hour]
Unity mobile game performance optimization series: performance tuning for the CPU side
The monitoring of Doris study notes
关于superset集成到自己的项目中