Home >Database >Mysql Tutorial >How to add comments to table in mysql
Mysql method to add comments to the table: You can use the comment keyword to add, the specific method is [create table user(in int, name varchar(30))comment = 'User information table';].
#In MySQL, add comments to tables and fields using the COMMENT keyword.
Related learning recommendations: mysql tutorial (video)
1. Add comments on tables and fields
Create a data table At the same time, add comments to tables and fields.
CREATE TABLE tb_user ( id INT AUTO_INCREMENT PRIMARY KEY COMMENT '编号', name VARCHAR(30) COMMENT '姓名' )COMMENT = '用户信息表';
2. Modify table comments
ALTER TABLE tb_user COMMENT '用户信息表2';
3. Modify field comments
Modifying field comments is actually modifying the definition of the field.
ALTER TABLE tb_user MODIFY COLUMN name VARCHAR(30) NOT NULL COMMENT '姓名2';
Note: When modifying, you must write the complete definition of the field, such as field type, attributes, etc. Never overwrite other attributes defined in this field just to modify a comment.
This article comes from the php Chinese website mysql graphic tutorial channel, welcome to learn!
4. Query field information
SHOW FULL COLUMNS FROM tb_user;
The above is the detailed content of How to add comments to table in mysql. For more information, please follow other related articles on the PHP Chinese website!