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 table comments by mysql

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

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to modify table notes in mysql". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In mysql, the statement that modifies a table comment is "alter table table name comment 'comment content;"; the alter statement is used to modify the structure of a table, either by adding or deleting columns, or by changing the table's comment and table type, and the comment attribute is used to represent the comment.

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

What is the statement that mysql modifies table comments? "alter table table name comment 'comment content';"

AlterTABLE allows you to modify the structure of an existing table. For example, you can add or delete columns, create or delete indexes, change the type of existing columns, or rename columns or tables themselves. You can also change the comments and types of tables.

Common usage of alter

1: delete column

ALTER TABLE [table name] DROP [column name]

2: add columns

ALTER TABLE [table name] ADD [column name] INT NOT NULL COMMENT 'comment description'

3: modify the type information of the column

ALTER TABLE [table name] CHANGE [column name] [new column name (here you can use the same name as the original column)] BIGINT NOT NULL COMMENT 'comment description'

4: rename the column

ALTER TABLE [table name] CHANGE [column name] [new column name] BIGINT NOT NULL COMMENT 'comment description'

5: rename the table

ALTER TABLE [Table name] RENAME [Table New name]

6: delete the primary key in the table

Alter TABLE [table name] drop primary key

7: add primary key

This is the end of ALTER TABLE sj_resource_charges ADD CONSTRAINT PK_SJ_RESOURCE_CHARGES PRIMARY KEY (resid,resfromid) "how to modify table comments by mysql". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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