当前位置:网站首页>Modifying table names, deleting tables, obtaining table information, and deleting table records on specified dates for common MySQL statements
Modifying table names, deleting tables, obtaining table information, and deleting table records on specified dates for common MySQL statements
2022-06-26 02:52:00 【Why is there a bug list】
List of articles
Preface
Why does the operation table use commands , Instead of using simple visual tools to operate directly ?
When the amount of data is small , Using visualization tools is obviously more user-friendly , Simple mouse click operation , Get started without learning .
But as the amount of data increases , It is not realistic to use visualization tools , such as : A big watch with 30million lines , How can we manage it by hand ?
Using the command line , Obviously, it is more convenient and less error prone .
How to modify the table name
give an example :
ALTER table A RENAME TO B;
Keep watch A Rename table B
How to delete a table
Use here drop Delete , About drop,delete,truncate See the difference between the two :
https://blog.csdn.net/GBS20200720/article/details/125128287?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165613788116782248557404%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165613788116782248557404&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2blogfirst_rank_ecpm_v1~rank_v31_ecpm-4-125128287-null-null.nonecase&utm_term=drop&spm=1018.2226.3001.4450
drop:
DROP TABLE A;
A Is the name of the watch
How to get the basic information of a table
select * from information_schema.tables where table_name=‘A’;
A Is the name of the watch
Here are some important parameters
TABLE_ROWS( The number of rows in the table ):39137335
AVG_ROW_LENGTH( Average length per row ):126
DATA_LENGTH( Data length ):4951375872
How to delete a table record on a specified date
Get the data three months ago sql:
SELECT *
FROM tp_order_cancel_log
WHERE add_time < curdate() - INTERVAL 3 MONTH
ORDER BY add_time DESC;
add_time It is the field of record creation time defined in my table ( More commonly used is create_time)
Delete data three months ago sql:
DELETE *
FROM tp_order_cancel_log
WHERE add_time < curdate() - INTERVAL 3 MONTH;
边栏推荐
- Multi surveyor Gongshu campus Xiao sir_ Page error in Jenkins
- Version management tool usage
- Golang--channel and select
- UTONMOS:以数字藏品助力华夏文化传承和数字科技发展
- Technology is to be studied
- Implement decorator pattern for servicecollection
- GD32 ADC采集电压
- MySQL必須掌握4種語言!
- Thirty ninth step
- MySQL updates records based on the queried data
猜你喜欢

The programmer's eight-year salary change has made netizens envious: you pay me one year's salary per month

Deep understanding of distributed cache design

Explain the JVM clearly at one time and don't be asked by the interviewer again

Introduction to bloc: detailed explanation of cube

Implement decorator pattern for servicecollection

【机器学习】基于多元时间序列对高考预测分析案例

Camtasia 2022 nouvelle vidéo d'ordinateur d'enregistrement ultra - clair

Google 推荐在 MVVM 架构中使用 Kotlin Flow

【解决】联想拯救者vmware启动虚拟机蓝屏重启问题

NoSQL之Redis配置与优化
随机推荐
Dreamcamera2 video recording, playing without sound, recording function is normal, using a third-party application for video recording, playing with sound
业务流程图设计
NoSQL之Redis配置与优化
我在中山,到哪里开户比较好?网上开户是否安全么?
I am in Zhongshan. Where can I open an account? Is it safe to open an account online?
How do I take a screenshot of the iPad? 7 ways to take quick screenshots of iPad
官方零基础入门 Jetpack Compose 的中文课程来啦!
Is it safe to open a securities account at the school of Finance and business in 2022?
How to open a stock account? Is it safe to open an account online?
无法上网问题解决过程
Camtasia 2022 new ultra clear recording computer video
Is it safe to trade stocks with a compass? How does the compass trade stocks? Do you need to open an account
音视频与CPU架构
[defect detection] automatic defect detection of printed circuit board based on Matlab GUI [including Matlab source code 1912]
Never criticize
R language survival analysis
The programmer's eight-year salary change has made netizens envious: you pay me one year's salary per month
Version management tool usage
【解决】CMake was unable to find a build program corresponding to “Unix Makefiles“.
在 R 中创建非线性最小二乘检验