Oracle查询数据表结构语句
select A.column_name,
A.data_type,
A.data_length,
A.data_precision,
A.Data_Scale,
A.nullable,
A.Data_default,
B.comments,
C.IndexCount
from user_tab_columns A,
user_col_comments B,
(select count(*) IndexCount, Column_Name
from User_Ind_Columns
where Table_Name = 'T_TFM_CROSSDIR_15M_FLOW'
group by Column_Name) C
where A.Table_Name = B.Table_Name
and A.Column_Name = B.Column_Name
and A.Column_Name = C.Column_Name(+)
and A.Table_Name = 'T_TFM_CROSSDIR_15M_FLOW' ;
解释:
select A.column_name 字段名,
A.data_type 数据类型,
A.data_length 长度,
A.data_precision整数位,
A.Data_Scale 小数位,
A.nullable 允许空值,
A.Data_default 缺省值,
B.comments 备注,
C.IndexCount 索引次数
from user_tab_columns A,
user_col_comments B,
(select count(*) IndexCount, Column_Name
from User_Ind_Columns
where Table_Name = '''' TABLE_TEST ''''
group by Column_Name) C
where A.Table_Name = B.Table_Name
and A.Column_Name = B.Column_Name
and A.Column_Name = C.Column_Name(+)
and A.Table_Name = '''' TABLE_TEST '''';
mysql查询表结构的语句:
SELECT DISTINCT
a.TABLE_SCHEMA,
a.TABLE_NAME,
a.COLUMN_NAME,
a.COLUMN_TYPE
FROM
information_schema.COLUMNS a
LEFT JOIN information_schema.TABLES b
ON a.TABLE_NAME = b.TABLE_NAME
WHERE a.TABLE_SCHEMA = 'ums' ;