当前位置:网站首页>数据库中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——————
边栏推荐
- [QT] add knowledge supplement of third-party database
- # 使用 KubeKey 搭建 Kubernetes/KubeSphere 环境的'心路(累)历程'
- Introduction to EtherCAT
- Avalanche problem and the use of sentinel
- HTB-Lame
- 岭回归和lasso回归
- VMware vSphere 6.7 virtualization cloud management 12. Vcsa6.7 update vCenter server license
- 别再说不会解决 “跨域“ 问题啦
- The best learning method in the world: Feynman learning method
- File upload and download
猜你喜欢
![[linear DP] longest common subsequence](/img/47/c3172422e997009facbada929adb1a.jpg)
[linear DP] longest common subsequence

Avalanche problem and the use of sentinel

Example of Huawei operator level router configuration | example of configuring optionc mode cross domain LDP VPLS

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

Overview of EtherCAT principle
![[exsi] transfer files between hosts](/img/c3/128b72aca6e030b2d4be2b6bddbc43.png)
[exsi] transfer files between hosts

倍福TwinCAT3 Ads相关错误详细列表

Huawei operator level router configuration example | configuration static VPLS example
![[applet project development -- JD mall] uni app commodity classification page (Part 2)](/img/f3/752f41f5b5cc16c8a71498ea9cabb5.png)
[applet project development -- JD mall] uni app commodity classification page (Part 2)

Chapter 03_ User and authority management
随机推荐
go实现命令行的工具cli
# 使用 KubeKey 搭建 Kubernetes/KubeSphere 环境的'心路(累)历程'
世界上最好的学习法:费曼学习法
C语言多线程编程入门学习笔记
岭回归和lasso回归
So easy 将程序部署到服务器
Summary of problems encountered in debugging positioning and navigation
完全背包问题
Let's just say I can use thousands of expression packs
ctfshow爆破wp
The 'mental (tiring) process' of building kubernetes/kubesphere environment with kubekey
Subnet division (10)
ES6解构语法详解
BluePrism注册下载并安装-RPA第一章
shell脚本使用两个横杠接收外部参数
[applet project development -- JD mall] uni app commodity classification page (Part 2)
Ctfshow blasting WP
实现pow(x,n)函数
Huawei operator level router configuration example | configuration static VPLS example
MySQL index --01--- design principle of index