Get the App
SLTechnology News&Howtos  ›  Database  › 

The method of adding comments to a table by mysql

Shulou Source: shulou.com Published: 2022-06-01 04:12:42 10月14日 Update

This article will explain in detail about mysql to add comments to the table method, Xiaobian think it is very practical, so share it for everyone to make a reference, I hope you can read this article after harvest.

mysql How to add comments to a table: You can use the comment keyword to add comments. For example, create user table (in int, name varchar(30))comment = 'user information table';].

In MySQL, add comments to tables and fields using the COMMENT keyword.

1. Add comments to tables and fields

Add comments to tables and fields as you create data tables.

CREATE TABLE tb_user( id INT AUTO_INCREMENT PRIMARY KEY COMMENT 'number', name VARCHAR(30) COMMENT 'name') COMMENT = ' user information table';

2. Modify table notes

ALTER TABLE tb_user COMMENT 'user information table2';

3. Modify field comments

To modify a field comment is to modify the field definition.

ALTER TABLE tb_user MODIFY COLUMN name VARCHAR(30) NOT NULL COMMENT 'Last name 2';

Note: When modifying, complete definition of the field should be written, such as field type, attribute, etc. Never modify a comment by overwriting other attributes defined by that field.

4. Query field information

SHOW FULL COLUMNS FROM tb_user; About mysql to add comments to the table method shared here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Tags: Fields comments methods information users keywords names properties more articles good practical content just at the same time remarks that is data datasheets Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Xiaomi MariaDB OPPO Reno Microsoft