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

边栏推荐
- 前4A高管搞代运营,拿下一个IPO
- 苹果产品在日本全面涨价,iPhone13涨19%
- Lumiprobe cell imaging study PKH26 cell membrane labeling kit
- 中英说明书丨人可溶性晚期糖基化终末产物受体(sRAGE)Elisa试剂盒
- indexof和includes的区别
- kubernetes命令入门(namespaces,pods)
- 数据仓库(四)之ETL开发
- Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
- Lake Shore 连续流动低温恒温器传输线
- Example explanation: move graph explorer to jupyterlab
猜你喜欢

2. Create your own NFT collections and publish a Web3 application to show them start and run your local environment

如何使用物联网低代码平台进行个人设置?

从零开始学 MySQL —数据库和数据表操作

华为云专家详解GaussDB(for MySQL)新特性

毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?

生鲜行业B2B电商平台解决方案,提高企业交易流程标准化和透明度

【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决

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

苹果产品在日本全面涨价,iPhone13涨19%

AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award
随机推荐
Specification of lumiprobe reactive dye indocyanine green
从零开始学 MySQL —数据库和数据表操作
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
Lake Shore—OptiMag 超导磁体系统 — OM 系列
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
Once the SQL is optimized, the database query speed is increased by 60 times
前4A高管搞代运营,拿下一个IPO
Redis 实现限流的三种方式
数据仓库(四)之ETL开发
Getting started with kubernetes command (namespaces, pods)
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
Altair HyperWorks 2022软件安装包和安装教程
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
Li Kou daily question - Day 32 -1232 Dotted line
助力数字经济发展,夯实数字人才底座—数字人才大赛在昆成功举办
ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing
Usage and underlying implementation principle of PriorityQueue
如何运营好技术相关的自媒体?
M91 fast hall measuring instrument - better measurement in a shorter time