当前位置:网站首页>MySQL command statement (personal summary)
MySQL command statement (personal summary)
2022-07-28 19:57:00 【Mountains and rivers don't grow old】
Catalog
1 Add sentences
1.1 Add information to the list
insert into table_name(list_name,list_name......) values('values1','values2'.......),('values1','values2'........);
1.2 Add column to table
The operation of adding columns is similar to the following line of code , among table_name Is the table name you want to modify ,last_name Is the column name you want to add ,varchar(10) You can change it to the data type and value range you want .
alter table table_name add last_name varchar(10);
2 Delete statements
2.1 Delete the specified column
alter table table_name drop last_name;
2.2 Delete the specified information
( Delete one or more records )
2.2.1 Delete the entire list
delete from table_name;
2.2.2 Delete a record
delete from table_name where list_name='values';
2.3 Clear data in table
delete from table_name;
truncate table table_name;
3 Modify the information
3.1 Modify database code
In the following code database_name Is the name of the database you want to set ,gb2312 You can replace it with your own encoding format
alter database database_name character set gb2312;
3.2 Modify the value type or range of a table column
The modification method is the same as the above examples
alter table table_name modify list_name varchar(10);
3.3 Modify the name of the table
now_name Current table name
new_name Modified table name
rename table now_name to new_name;
3.4 Modify the character set encoding format of the table to utf-8
alter table table_name character set utf-8;
3.5 Change column names
alter table table_name change column name list_name varchar(100);
3.6 Modify the record
The first line of code simply modifies the data
The second line can add or subtract data on the original basis
update table_name set list_name=values,list_name=values where list_name=values;
update table_name set list_name=value+1000 where list_name=value;
4 Export import database
== Get into cmd ==
4.1 Export database (sql Script )
mysqldump -u user name -p Database name > Exported file name
mysqldump -u root -p db_name > test_db.sql
4.2 mysql Export a database table
mysqldump -u user name -p Database name Table name > Exported file name
mysqldump -u wcnc -p test_db users> test_users.sql ( There is no semicolon at the end )
4.3 mysql Import database
source File directory / name .sql
5 Query information
5.1 Query table structure
desc table_name;
边栏推荐
- Convertible bond concept table x notation gives you a convenient and fast experience!
- Salt SSH of saltstack
- 软考高级考试中有五大证书,哪个更值得考?
- Intermediate soft test (system integration project management engineer) high frequency test site
- Leetcode day3 find duplicate email addresses
- Redis笔记
- How does app automated testing achieve H5 testing
- In order to develop high-end photoresist, Jingrui Co., Ltd. invested 75million yuan to purchase SK Hynix ASML lithography machine
- 毕马威中国:证券基金经营机构信息技术审计项目发现洞察
- MySQL performance testing tool sysbench learning
猜你喜欢

2022年全国最新消防设施操作员(中级消防设施操作员)题库及答案

云计算笔记part.2——应用管理

数字滤波器设计——Matlab

11、 学习MySQL UNION 操作符

MATLAB实现的图像分割之边缘检测和连接

云原生编程挑战赛火热开赛,51 万奖金等你来挑战!

Kubeedge releases white paper on cloud native edge computing threat model and security protection technology

Basic usage of docker

Cloud computing notes part.1 - system management

Deploy LNMP automatically with saltstack
随机推荐
Leetcode day2 连续出现的数字
English translation Italian - batch English translation Italian tools free of charge
Germany and Portugal have announced that they will not disable Huawei 5g equipment, but Germany will set strict restrictions!
leetcode day1 分数排名
架构基本概念和架构本质
基于MATLAB的函数拟合
There are five certificates in the soft examination advanced examination, which is more worth taking?
助力面板行业创新,FPGA将成屏厂TCON最佳选择?
Leetcode day3 find duplicate email addresses
美国将提供250亿美元补贴,鼓励英特尔等芯片制造商迁回产线
CodeIgnier框架实现restful API接口编程
High beam software has obtained Alibaba cloud product ecological integration certification, and is working with Alibaba cloud to build new cooperation
MATLAB实现的图像分割之边缘检测和连接
Huawei shares in Nanjing core vision, laying out the solid-state laser radar chip field
芯片功耗性能验证:从困境到超越
How to write the SQL statement of time to date?
一文读懂如何部署具有外部数据库的高可用 K3s
“中国网事·感动2022”二季度网络感动人物评选结果揭晓
Know small and medium LAN WLAN
Cloud computing notes part.2 - Application Management