常用的四种数据库类型如下:
Mysql database:
select column_name,column_type,column_comment from information_schema.COLUMNS where table_name = '表名' and table_schema = '数据库名';
Oracle database:
-- 查询所有用户下的相同表名的列都查询出来,会造成重复和错误
select column_name, data_type from all_tab_columns where TABLE_NAME = '表名'
-- 查询某一用户下某张表的内容
select column_name, data_type, data_length from user_tab_columns where TABLE_NAME = '表名' ;
SQLServer database
select column_name,data_type from information_schema.columns where table_name = '表名'
Postgresql database
select column_name, data_type from information_schema.columns where table_name = '表名' ORDER BY ordinal_position;