当前位置:网站首页>从零开始学 MySQL —数据库和数据表操作
从零开始学 MySQL —数据库和数据表操作
2022-07-01 18:42:00 【InfoQ】

- 数据库操作:删除数据库、修改数据库。
- 数据表操作:重命名表、删除表、指定位置增加一列数据、删除一列、重命名一列、更改数据类型、删除一行记录。
https://github.com/rongweihe/MoreThanCode/tree/master/mysql_shiyan#打开 MySQL 服务
sudo service mysql start
#使用 root 用户登录
mysql -u rootsource /home/MySQL_05_01.sql;

【文章福利】另外小编还整理了一些C++后端开发面试题,教学视频,后端学习路线图免费分享,需要的可以自行添加:
学习交流群点击加入~
群文件共享
小编强力推荐C++后端开发免费学习地址:
C/C++Linux服务器开发高级架构师/C++后台开发架构师

RENAME TABLE 原名 TO 新名字;
ALTER TABLE 原名 RENAME 新名;
ALTER TABLE 原名 RENAME TO 新名;use mysql_shiyanRENAME TABLE table_1 TO table_2;
DROP TABLE 表名字;DROP TABLE table_2;
3.3 增加一列
对表结构的修改,会实际影响数据表的结构,有时候一些小的错误会造成不可挽回的后果,所以谨慎细心操作。在实际生产环境中,一定要得到上级领导的许可,否则不要轻易修改。
我们来看看,在表中增加一列的语句格式为:
ALTER TABLE 表名字 ADD COLUMN 列名字 数据类型 约束;
ALTER TABLE 表名字 ADD 列名字 数据类型 约束;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 删除一列
ALTER TABLE 表名字 DROP COLUMN 列名字;
或:ALTER TABLE 表名字 DROP 列名字;ALTER TABLE employee DROP test;
ALTER TABLE 表名字 CHANGE 原列名 新列名 数据类型 约束;ALTER TABLE employee CHANGE height shengao INT(4) DEFAULT 170;
3.6 改变数据类型
ALTER TABLE 表名字 MODIFY 列名字 新数据类型;UPDATE 表名字 SET 列1=值1,列2=值2 WHERE 条件;UPDATE employee SET age=25 ,salary=20000 WHERE name='xiaowei';
3.8 删除一行记录
DELETE FROM 表名字 WHERE 条件;DELETE FROM employee WHERE name='xiaohong';
4、总结
参考资料

边栏推荐
- Altair HyperWorks 2022 software installation package and installation tutorial
- Mipi interface, DVP interface and CSI interface of camera [easy to understand]
- M91 fast hall measuring instrument - better measurement in a shorter time
- Viewing technological changes through Huawei Corps (VI): smart highway
- [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
- Lake Shore—CRX-EM-HF 型低温探针台
- 斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测
- Lumiprobe 细胞成像研究丨PKH26细胞膜标记试剂盒
- VBA simple macro programming of Excel
- The former 4A executives engaged in agent operation and won an IPO
猜你喜欢

11、用户、组和权限(1)

洞态在某互联⽹⾦融科技企业的最佳落地实践

Lumiprobe 自由基分析丨H2DCFDA说明书

用GSConv+Slim Neck改进Yolov5,将性能提升到极致!

B2B e-commerce platform solution for fresh food industry to improve the standardization and transparency of enterprise transaction process

实例讲解将Graph Explorer搬上JupyterLab

11. Users, groups, and permissions (1)

Why do independent website sellers start to do social media marketing? The original customer conversion rate can be improved so much!

How to realize the applet in its own app to realize continuous live broadcast

Summary of the core steps in the life cycle of beans
随机推荐
More information about M91 fast hall measuring instrument
indexof和includes的区别
Openai video pre training (VPT): action learning based on watching unmarked online videos
Gameframework eating guide
How to realize the applet in its own app to realize continuous live broadcast
C端梦难做,科大讯飞靠什么撑起10亿用户目标?
Is PMP cancelled??
ES6数组去重的三个简单办法
golang 错误处理
AppGallery Connect场景化开发实战—图片存储分享
Clean up system cache and free memory under Linux
Superoptimag superconducting magnet system - SOM, Som2 series
OpenAI|视频预训练 (VPT):基于观看未标记的在线视频的行动学习
Lumiprobe 细胞成像研究丨PKH26细胞膜标记试剂盒
【直播预约】数据库OBCP认证全面升级公开课
Golang error handling
CDGA|从事通信行业,那你应该考个数据管理证书
Altair HyperWorks 2022 software installation package and installation tutorial
Huawei game failed to initialize init with error code 907135000
Lake shore optimag superconducting magnet system om series