Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to annotate mysql datasheets and fields?

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

mysql creates tables with explanations and adds comments to tables and fields:

1. Create a table with explanations

CREATE TABLE test_table( t_id INT(11) PRIMARY KEY AUTO_INCREMENT COMMENT 'SET PRIMARY KEY AUTO INCREMENT', t_name VARCHAR(64) COMMENT 'COLUMN COMMENT') COMMENT ='TABLE COMMENT ';

2. Modify table notes

ALTER TABLE test_table COMMENT 'modify table comment';

3. View table notes

SELECT TABLE_COMMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'test_table'

4. Add columns with comments

alter table test_table add t_age int(11) comment 'AGE'

5. Modify column names with comments

ALTER TABLE test_table CHANGE t_age t_sex VARCHAR(4) COMMENT 'sex'

6. Modify column comments

ALTER TABLE test_table MODIFY COLUMN t_sex VARCHAR(30) NOT NULL COMMENT 'male female'

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.

7. Delete columns

alter table test_table drop column t_sex

8. Query table field information

SHOW FULL COLUMNS FROM test_table

9. Delete table

--Single deletion drop table--Batch deletion drop table Table 1, Table 2, Table 3

10. Modify a field value in batches

UPDATE test_table SET t_name = REPLACE(t_name, 'test', 't')

As shown in the figure:

Example: Before running

Post Run:

The above is mysql for data tables and fields to add comments details, more please pay attention to other related articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report