Home >Database >Mysql Tutorial >What is the statement to modify table comments in mysql

What is the statement to modify table comments in mysql

WBOY
WBOYOriginal
2022-04-12 18:19:476016browse

In mysql, the statement to modify table comments is "alter table table name comment 'comment content';"; the alter statement is used to modify the structure of a table. It can add or delete columns, or change the table. The type of comment and table. The comment attribute is used to represent comments.

What is the statement to modify table comments in mysql

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

What is the statement in mysql to modify table comments

“alter table 表名 comment '注释内容';”

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 the table itself. You can also change the table annotation and the table type.

Common usage of alter

1: Delete a column

ALTER TABLE 【表名字】 DROP 【列名称】

2: Add a column

ALTER TABLE 【表名字】 ADD 【列名称】 INT NOT NULL  COMMENT '注释说明'

3: Modify the type information of a column

ALTER TABLE 【表名字】 CHANGE 【列名称】【新列名称(这里可以用和原来列同名即可)】 BIGINT NOT NULL  COMMENT '注释说明'

4: Rename column

ALTER TABLE 【表名字】 CHANGE 【列名称】【新列名称】 BIGINT NOT NULL  COMMENT '注释说明'

5: Rename table

ALTER TABLE 【表名字】 RENAME 【表新名字】

6: Delete primary key in table

Alter TABLE 【表名字】 drop primary key

7: Add primary key

ALTER TABLE sj_resource_charges ADD CONSTRAINT PK_SJ_RESOURCE_CHARGES PRIMARY KEY (resid,resfromid)

Recommended learning: mysql video tutorial

The above is the detailed content of What is the statement to modify table comments in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn