Get the App
SLTechnology News&Howtos  ›  Database  › 

How to modify table comments by mysql

Shulou Source: shulou.com Published: 2022-05-31 10:50:21 10月16日 Update

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!

Tags: Comments names contents types statements more knowledge structure practicality achievement next information dilemma reality attributes common situation tutorials articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Redmi Apple Shulou Tech Info Shulou Technology