How to annotate mysql datasheets and fields?
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!