有时我们需要对数据进行探究,首先想到的就是该表有哪些字段,以及字段类型、注释,那么我们该如何快速的知道呢?
可参考下列的
1、查询 Test 数据库中有哪些表,查询结果如下:
2、查询 Test 数据库中 test_01 表的字段名、字段类型、字段类型 + 长度,查询结果如下:
3、查询 Test 数据库中 test_01 表的字段名、注释,查询结果如下:
SQL 汇集:
字段说明:
information_schema.tables
表名 :table_name
字段列名:column_name
字段注释:column_comment
字段类型:data_type
字段类型 + 长度 :column_type
-- 创建 test_01 表
create table Test.test_01(tID int,name varchar(10) COMMENT '名字',sex varchar(10) COMMENT '性别');
-- 1、查询Test数据库有哪些表
select table_name from information_schema.tables where table_schema='Test';
-- 2、查询 Test 数据库中 test_01 表的字段名、字段类型、字段类型 + 长度
select column_name,data_type,column_type
from information_schema.columns
where table_schema = 'Test' and table_name = 'test_01';
-- 3、查询 Test 数据库中 test_01 表的字段名、注释
select column_name,column_comment from information_schema.columns
where table_schema = 'Test' and table_name = 'test_01';
希望对你有帮助!!