How to add comments to data tables and fields by mysql
This article mainly explains "mysql how to add comments to data tables and fields", the content of the explanation is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "mysql how to add comments to data tables and fields" bar!
Specific steps for mysql to create an interpreted table and add comments to the table and fields:
1. Create a table with explanation
CREATE TABLE test_table (t_id INT (11) PRIMARY KEY AUTO_INCREMENT COMMENT 'set key self-increment', t_name VARCHAR (64) COMMENT 'column comments') COMMENT=' Notes'
2. Modify the table notes
ALTER TABLE test_table COMMENT 'modify table comments'
3. Check the table notes (free study video tutorial sharing: mysql video tutorial)
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 the column name with comments
ALTER TABLE test_table CHANGE t_age t_sex VARCHAR (4) COMMENT 'gender'
6. Modify column comments
ALTER TABLE test_table MODIFY COLUMN t_sex VARCHAR (30) NOT NULL COMMENT 'male and female'
Note: when modifying, write down the complete definition of the field, such as field type, properties, etc. Never overwrite other properties defined in the field just to modify a comment.
7. Delete columns
Alter table test_table drop column t_sex
8. Query table field information
SHOW FULL COLUMNS FROM test_table
9. Delete the table
-- single delete drop table table-- batch delete drop table Table 1, Table 2, Table 3
10. Modify a field value in batch
UPDATE test_table SET t_name = REPLACE (t_name, 'test', 't') Thank you for your reading, this is the content of "how mysql adds comments to data tables and fields". After the study of this article, I believe you have a deeper understanding of how mysql adds comments to data tables and fields, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!