Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify the structure of mysql database table

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to modify the mysql database table structure, has a certain reference value, friends in need can refer to. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

Methods to modify the mysql database table structure: 1, view the table structure; 2, add columns; 3, delete columns, code is [mysql > alter table student drop column birthday]; 4, modify columns, code is [mysql > alter table].

How to modify the structure of mysql database tables:

1. View the table structure

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. Add columns

Mysql > alter table student add column birthday datetime;Query OK, 0 rows affected (2.06 sec) Records: 0 Duplicates: 0 Warnings: 0

3. Delete columns

Mysql > alter table student drop column birthday;Query OK, 0 rows affected (0.80 sec) Records: 0 Duplicates: 0 Warnings: 0

4. Modify the column

-1. Modify the column type mysql > alter table student modify age int not null;Query OK, 0 rows affected (0.09 sec) Records: 0 Duplicates: 0 Warnings: 0-- 2. Modify the name of the column mysql > alter table student change column name sname varchar (20); Query OK, 0 rows affected (1.31 sec) Records: 0 Duplicates: 0 Warnings: 0 Thank you for reading this article carefully. I hope it will be helpful for everyone to share how to modify the structure of the mysql database table. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report