有时我们需要对数据进行探究,首先想到的就是该表有哪些字段,以及字段类型、注释,那么我们该如何快速的知道呢?
可参考下列的示例
1、查看 Test 数据库的所有表
-- 方法一
select name from system.tables where database = 'Test';
-- 方法二
select distinct table from system.columns where database = 'Test';
2、查看 Test_table 表的所有字段
select name from system.columns where database = 'Test' and table='Test_table';
3、查看 Test_table 表的字段名、字段类型、字段注释
select database,table,name,type,comment from system.columns where database = 'Test' and table='Test_table';
4、若想就看某个表的某一两个字段的字段类型的话,可直接 调用 toTypeName() 函数来查看
select top 1 toTypeName(`id`),toTypeName(`name`) from Test_table;
希望对你有帮助。