修改mysql数据库表结构的方法:1、查看表结构;2、添加列;3、删除列,代码为【mysql> alter table student drop column birthday】;4、修改列,代码为【mysql> alter table】。

本教程操作环境:windows7系统、mysql 8.0.22版、thinkpad t480电脑。
相关免费学习推荐:mysql数据库(视频)
修改mysql数据库表结构的方法:
1、查看表结构
mysql> show create table student;+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Table | Create Table |+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| student | CREATE TABLE `student` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `NAME` varchar(20) NOT NULL, `AGE` int(11) NOT NULL, PRIMARY KEY (`ID`)) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 |+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+1 row in set (0.09 sec)
2、添加列
图改改
在线修改图片文字
455 查看详情
mysql> alter table student add column birthday datetime;Query OK, 0 rows affected (2.06 sec)Records: 0 Duplicates: 0 Warnings: 0
3、删除列
mysql> alter table student drop column birthday;Query OK, 0 rows affected (0.80 sec)Records: 0 Duplicates: 0 Warnings: 0
4、修改列
--1.修改列的类型mysql> alter table student modify age int not null;Query OK, 0 rows affected (0.09 sec)Records: 0 Duplicates: 0 Warnings: 0 --2.修改列的名称mysql> alter table student change column name sname varchar(20);Query OK, 0 rows affected (1.31 sec)Records: 0 Duplicates: 0 Warnings: 0
相关免费学习推荐:编程视频
以上就是如何修改mysql数据库表结构的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/293517.html
微信扫一扫
支付宝扫一扫