当前位置:网站首页>数据库中COMMENT关键字的使用
数据库中COMMENT关键字的使用
2022-07-01 03:14:00 【苡荏】
COMMENT的使用介绍
作用:为字段或列添加注释。
1. 创建表时为字段添加注释
CREATE TABLE emp(
emp_id INT PRIMARY KEY AUTO_INCREMENT COMMENT '编号',
emp_name CHAR(20) NOT NULL DEFAULT '' COMMENT '姓名',
salary DECIMAL(10,2) NOT NULL DEFAULT 0 COMMENT '工资',
department CHAR(20) NOT NULL DEFAULT '' COMMENT '部门'
);
2. 创建表后为字段添加注释
ALTER TABLE emp CHANGE COLUMN department department CHAR(20) NOT NULL DEFAULT '' COMMENT '部门';
3. 查看表中所有字段的注释
- 方式1
show full columns from tablename;
SHOW FULL COLUMNS FROM emp;

- 方式2
SELECT * FROM COLUMNS WHERE TABLE_SCHEMA='dbname' AND TABLE_NAME='tablename';

4. 创建表时为表添加注释
CREATE TABLE test(
field_name INT
)COMMENT="注释内容";
5. 创建表后为表添加注释
alter table tablename comment '表注释内容';
6. 查看表注释
- 方式1
show create table tablename;

- 方式2
USE information_schema;
SELECT * FROM TABLES WHERE TABLE_SCHEMA='dbname' AND TABLE_NAME='tablename';

——————END-2022-06-11——————
边栏推荐
猜你喜欢

Cookie&Session

咱就是说 随便整几千个表情包为我所用一下

后台系统页面左边菜单按钮和右边内容的处理,后台系统页面出现双滚动

几行事务代码,让我赔了16万

实战 ELK 优雅管理服务器日志

File upload and download

伺服第二编码器数值链接到倍福PLC的NC虚拟轴做显示

Learning notes for introduction to C language multithreaded programming

Cloud native annual technology inventory is released! Ride the wind and waves at the right time
![Install vcenter6.7 [vcsa6.7 (vCenter server appliance 6.7)]](/img/83/e3c9d8eda9d5351d4c54928d3b090b.png)
Install vcenter6.7 [vcsa6.7 (vCenter server appliance 6.7)]
随机推荐
Data exchange JSON
Huawei operator level router configuration example | BGP VPLS configuration example
EtherCAT简介
Druid monitoring statistics source
multiple linear regression
BluePrism注册下载并安装-RPA第一章
Basic concept and classification of sorting
JS日常开发小技巧(持续更新)
Chapitre 03 Bar _ Gestion des utilisateurs et des droits
About the application of MySQL
后台系统页面左边菜单按钮和右边内容的处理,后台系统页面出现双滚动
XXL job User Guide
[QT] add knowledge supplement of third-party database
【EXSI】主机间传输文件
Ctfshow blasting WP
JUC学习
监听器 Listener
So easy deploy program to server
POI导出excel,按照父子节点进行分级显示
Kmeans