几种常用数据库字段类型查询语句

这里总结几个数据库的查询所有表字段名和字段类型的SQL语句:

Mysql database:

select COLUMN_NAME, DATA_TYPE from information_schema.COLUMNS where table_name =

注意:这样查询能把所有数据库中table_name为该名字的表查询出来;如果要指定数据库可以所有下面的语句:

select COLUMN_NAME,DATA_TYPE from information_schema.COLUMNS  where table_name = ' tableName'  and table_schema = ' database ';

Oracle database:

select column_name, data_type from all_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 = 'ahnavi' ORDER BY ordinal_position;

posted @ 2017-03-16 13:40    阅读(768)  评论(0编辑  收藏  举报