Home > Database > navicat > body text

How to display field comments in Navicat

爱喝马黛茶的安东尼
Release: 2019-08-21 14:57:30
Original
23828 people have browsed it

How to display field comments in Navicat

In the MySQL database, comments on fields or columns are added using the comment attribute.

In the script that creates a new table, you can add comments by adding the comment attribute in the field definition script.

The sample code is as follows:

create table test(
id int not null default 0 comment ‘用户id’
)
Copy after login

If the table has been built, you can also use the command to modify the fields, and then add the comment attribute definition to add comments.

The sample code is as follows:

alter table test
change column id id int not null default 0 comment ‘测试表id’
Copy after login

Related recommendations: "Navicat for mysql usage tutorial"

How about viewing the comments of all fields in an existing table?

You can use the command:

show full columns from table;
Copy after login

Examples are as follows:

show full columns from test;
Copy after login

1. Write comments when creating the table

create table test1
(
field_name int comment ‘字段的注释’
)comment=‘表的注释’;
Copy after login

2. Modify the comments of the table

alter table test1 comment ‘修改后的表的注释’;
Copy after login

3. Modify the comments of the field

alter table test1 modify column field_name int comment ‘修改后的字段注释’;
Copy after login

-Note: Just write the field name and field type exactly as they are

4. How to view the table comments

– Look at

show create table test1;
Copy after login

in the generated SQL statement – ​​Look at

use information_schema;
select * from TABLES where TABLE_SCHEMA=‘my_db’ and TABLE_NAME=‘test1’ \G
Copy after login

in the metadata table 5. How to view field comments

–show
show full columns from test1;
Copy after login

– Look at the metadata table Look inside

select * from COLUMNS where TABLE_SCHEMA=‘my_db’ and TABLE_NAME=‘test1’ \G
Copy after login

When using the tool Navicat, it is easier to add comments.

Right-click to select the table that needs to be commented. You can see the comment COMMENT under DDL in the object information.

How to display field comments in Navicat

Right-click and select "Design Table", you can see the comments below, click "Add".

How to display field comments in Navicat

The above is the detailed content of How to display field comments in Navicat. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!