当前位置:网站首页>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;
边栏推荐
猜你喜欢
Deep understanding of distributed cache design
Interviewer: please name four ways to exchange the values of two variables without using third-party variables
OpenAPI 3.0 specification - Food Guide
[machine learning] case study of college entrance examination prediction based on multiple time series
分享一些在内网操作的远程办公经验| 社区征文
2022-06-25:给定一个正数n, 表示有0~n-1号任务, 给定一个长度为n的数组time,time[i]表示i号任务做完的时间, 给定一个二维数组matrix, matrix[j] = {a,
Here comes the official zero foundation introduction jetpack compose Chinese course!
学习太极创客 — MQTT(五)发布、订阅和取消订阅
Redis Lua沙盒绕过命令执行(CVE-2022-0543)
IPhone 13 screen stuck black, unable to shut down? How to solve
随机推荐
OpenAPI 3.0 specification - Food Guide
Dreamcamera2 record key prompt sound into video during video recording
【机器学习】基于多元时间序列对高考预测分析案例
用指南针交易股票安全吗?指南针是如何交易股票的,需要开户吗
OpenAPI 3.0 规范-食用指南
MySQL根据查询的数据更新记录
Remember a simple JVM tuning experience
数据库查询语句SQL中like、%、-的区别
Blazor University (33) form - editcontext, fieldidentifiers
Teach you to quickly record sounds on PC web pages as audio files
版本管理工具使用
How to solve the problem that the iPhone 13 lock screen cannot receive the wechat notification prompt?
[solution] cmake was unable to find a build program corresponding to "UNIX makefiles"
音视频与CPU架构
力扣(LeetCode)176. 第二高的薪水(2022.06.25)
What is the sudden power failure of iPhone and how to solve it?
How do I take a screenshot of the iPad? 7 ways to take quick screenshots of iPad
Oracle练习
Possible values for @supply in kotlin
请指教同花顺软件究竟是什么?在线开户安全么?