Directly post code and examples #Write comments when creating a table CREATE TABLE userinfo( id INT COMMENT 'Number', uname VARCHAR(40) COMMENT 'User name', address VARCHAR(120) COMMENT 'Home address', hobby VARCHAR(200) COMMENT 'hobby' )COMMENT = 'User information table'; #Modify the comment of the table ALTER TABLE userinfo COMMENT 'User information table'; #Modify the comment of the field. Note: just write the field name and field type. ALTER TABLE userinfo MODIFY COLUMN uname VARCHAR(40) COMMENT 'name'; #To view the table comments, see SHOW CREATE TABLE userinfo in the generated SQL statement; #Look in the metadata table USE information_schema; SELECT * FROM TABLES WHERE TABLE_SCHEMA='shoppingcart' AND TABLE_NAME='userinfo'; #Method to view field comments SHOW FULL COLUMNS FROM userinfo; #Look in the metadata table SELECT * FROM COLUMNS WHERE TABLE_SCHEMA='shoppingcart' AND TABLE_NAME='userinfo'; Supplement: MySQL adds fields and comments to existing data tablesProblem Description: In the process of developing a system, it is often necessary to appropriately modify the original table structure as the system service functions expand or the relationship between services is expanded, for example, adding some necessary fields. Example: Add three fields: device IP, device name, and device type to the existing device table device. Problem Solving Method 1 (Command line method) ALTER TABLE device ADD COLUMN `device_ip` VARCHAR(32) DEFAULT NULL COMMENT 'Device IP'; ALTER TABLE device ADD COLUMN `device_name` VARCHAR(128) DEFAULT NULL COMMENT 'Device name'; ALTER TABLE device ADD COLUMN `device_type` VARCHAR(32) DEFAULT NULL COMMENT 'Device type'; or ALTER TABLE device ADD COLUMN (`device_ip` VARCHAR(32) DEFAULT NULL COMMENT 'Device IP', `device_name` VARCHAR(128) DEFAULT NULL COMMENT 'Device name', `device_type` VARCHAR(32) DEFAULT NULL COMMENT 'Device type'); Method 2 (Client Tool Method) Use MySQL visualization tools, such as SQLyog, Navicat. Right-click the table name-->Select Design Table-->Add fields, fill in the corresponding properties, and save. This is the end of this article about how to add field comments to MySQL table creation. For more relevant content about adding field comments to MySQL, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Vue uses Canvas to generate random sized and non-overlapping circles
>>: Summary of tips for making web pages
This article shares a sharing sidebar implemented...
This article mainly introduces the sample code of...
Copy code The code is as follows: <!-- Prevent...
Now, more and more front-end developers are starti...
Table of contents Preface text Primitive types Pr...
There is no need to say much about the difference...
Preface To help ensure that your web pages have a ...
1. Perform file name search which (search for ...
When using the docker-maven-plugin plug-in, Maven...
Table of contents environment Virtual Machine Ver...
Definition of Float Sets the element out of the n...
Personal implementation screenshots: Install: npm...
Table of contents 1.DB,DBMS,SQL 2. Characteristic...
Description of the problem: When the number of as...
Table of contents Linux 1. Basic use of crontab 2...