当前位置:网站首页>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 rootsource /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_shiyanRENAME 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

边栏推荐
- JS find the next adjacent element of the number in the array
- How to realize the applet in its own app to realize continuous live broadcast
- R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graph, and uses PCH parameters to customize the shape o
- 1. "Create your own NFT collections and publish a Web3 application to show them." what is NFT
- 【pytorch记录】模型的分布式训练DataParallel、DistributedDataParallel
- Clean up system cache and free memory under Linux
- Manufacturing SRM management system supplier all-round closed-loop management, to achieve procurement sourcing and process efficient collaboration
- Create your own NFT collections and publish a Web3 application to show them (Introduction)
- 云服务器ECS夏日省钱秘籍,这次@老用户快来领走
- Appgallery connect scenario development practice - image storage and sharing
猜你喜欢

How to use the low code platform of the Internet of things for personal settings?

Is PMP cancelled??

Three. JS learning - basic operation of camera (learn from)

C端梦难做,科大讯飞靠什么撑起10亿用户目标?

混沌工程平台 ChaosBlade-Box 新版重磅发布

一次SQL优化,数据库查询速度提升 60 倍

Getting started with kubernetes command (namespaces, pods)

【AGC】如何解决事件分析数据本地和AGC面板中显示不一致的问题?

市值蒸发740亿,这位大佬转身杀入预制菜

Specification of lumiprobe reactive dye indocyanine green
随机推荐
Digital business cloud: from planning to implementation, how does Minmetals Group quickly build a new pattern of digital development?
B2B e-commerce platform solution for fresh food industry to improve the standardization and transparency of enterprise transaction process
数据库基础:select基本查询语句
R language ggplot2 visualization: gganimate creates a dynamic histogram animation (GIF), and displays the histogram and enter step by step along a given dimension in the animation_ Growth function and
Go language self-study series | go language data type
网易游戏,激进出海
Lumiprobe cell imaging study PKH26 cell membrane labeling kit
SuperOptiMag 超导磁体系统 — SOM、SOM2 系列
Yyds dry inventory ravendb start client API (III)
Three. JS learning - basic operation of camera (learn from)
Qt中的QFile读写文件操作
Solution: you can ping others, but others can't ping me
一次SQL优化,数据库查询速度提升 60 倍
太爱速M源码搭建,巅峰小店APP溢价寄卖源码分享
Gameframework eating guide
ES6数组去重的三个简单办法
Once the SQL is optimized, the database query speed is increased by 60 times
组队学习! 14天鸿蒙设备开发“学练考”实战营限时免费加入!
VBA simple macro programming of Excel
The R language cartools package divides the data, the scale function scales the data, the KNN function of the class package constructs the k-nearest neighbor classifier, and the table function calcula