当前位置:网站首页>Learn MySQL from scratch - database and data table operations
Learn MySQL from scratch - database and data table operations
2022-07-01 19:16:00 【InfoQ】

- Database operation : Delete database 、 modify the database .
- Data table operation : rename table 、 Delete table 、 Add a column of data at the specified position 、 Delete a column 、 Rename a column 、 Change data type 、 Delete a row of records .
https://github.com/rongweihe/MoreThanCode/tree/master/mysql_shiyan
# open MySQL service
sudo service mysql start
# Use root The user login
mysql -u root
source /home/MySQL_05_01.sql;


【 Article Welfare 】 In addition, Xiaobian also sorted out some C++ Back-end development interview questions , Teaching video , Back end learning roadmap for free , You can add what you need :
Click to join the learning exchange group ~
Group file sharing
Xiaobian strongly recommends C++ Back end development free learning address :
C/C++Linux Server development senior architect /C++ Background development architect

RENAME TABLE Original name TO New name ;
ALTER TABLE Original name RENAME New name ;
ALTER TABLE Original name RENAME TO New name ;
use mysql_shiyan
RENAME TABLE table_1 TO table_2;

DROP TABLE Table name ;
DROP TABLE table_2;

3.3 Add a row
Modification of table structure , It will actually affect the structure of the data table , Sometimes small mistakes can have irreparable consequences , So operate carefully . In the actual production environment , Be sure to get the permission of your superiors , Otherwise, do not modify it easily .
Let's see , Add a column to the table in the form of :
ALTER TABLE Table name ADD COLUMN Name data type constraint ;
ALTER TABLE Table name ADD Name data type constraint ;
ALTER TABLE employee ADD height INT(4) DEFAULT 170;

ALTER TABLE employee ADD weight INT(4) DEFAULT 120 AFTER age;

ALTER TABLE employee ADD test INT(10) DEFAULT 11 FIRST;

3.4 Delete a column
ALTER TABLE Table name DROP COLUMN Name ;
or :ALTER TABLE Table name DROP Name ;
ALTER TABLE employee DROP test;

ALTER TABLE Table name CHANGE The original name New column names data type constraint ;
ALTER TABLE employee CHANGE height shengao INT(4) DEFAULT 170;

3.6 Change the data type
ALTER TABLE Table name MODIFY Name New data types ;
UPDATE Table name SET Column 1= value 1, Column 2= value 2 WHERE Conditions ;
UPDATE employee SET age=25 ,salary=20000 WHERE name='xiaowei';

3.8 Delete a row of records
DELETE FROM Table name WHERE Conditions ;
DELETE FROM employee WHERE name='xiaohong';

4、 summary
Reference material

边栏推荐
- Solution of digital supply chain centralized purchase platform in mechanical equipment industry: optimize resource allocation and realize cost reduction and efficiency increase
- Leetcode203 remove linked list elements
- 机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效
- 前4A高管搞代运营,拿下一个IPO
- 3. "Create your own NFT collections and publish a Web3 application to show them" cast NFT locally
- ES6数组方法find()、findIndex()的总结「建议收藏」
- 洞态在某互联⽹⾦融科技企业的最佳落地实践
- Lake Shore M91快速霍尔测量仪
- 11、用户、组和权限(1)
- Summary of cases of players' disconnection and reconnection in Huawei online battle service
猜你喜欢
nacos配置文件发布失败,请检查参数是否正确的解决方案
docker 部署mysql8.0
AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award
Lake Shore M91快速霍尔测量仪
11、用户、组和权限(1)
Superoptimag superconducting magnet system - SOM, Som2 series
The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise
M91 fast hall measuring instrument - better measurement in a shorter time
Netease games, radical going to sea
M91快速霍尔测量仪—在更短的时间内进行更好的测量
随机推荐
R language uses the aggregate function of epidisplay package to divide numerical variables into different subsets based on factor variables, and calculate the summary statistics of each subset
MySQL common graphics management tools | dark horse programmers
【直播预约】数据库OBCP认证全面升级公开课
MySQL常用图形管理工具 | 黑马程序员
Appgallery connect scenario development practice - image storage and sharing
Three simple methods of ES6 array de duplication
PostgreSQL varchar[] 数组类型操作
linux下清理系统缓存并释放内存
Redis 实现限流的三种方式
Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency
Example explanation: move graph explorer to jupyterlab
Graduation summary
M91快速霍尔测量仪—在更短的时间内进行更好的测量
app发版后的缓存问题
精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会
Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
Summary of cases of players' disconnection and reconnection in Huawei online battle service
Viewing the whole ecology of Tiktok from a macro perspective
Summary of the core steps in the life cycle of beans
PriorityQueue的用法和底层实现原理