Oracle:
1、查询某个表中的字段名称、类型、精度、长度、是否为空
select COLUMN_NAME,DATA_TYPE,DATA_PRECISION,DATA_SCALE,NULLABLE
from user_tab_columns
where table_name ='YourTableName'
2、查询某个表中的主键字段名
select col.column_name
from user_constraints con, user_cons_columns col
where con.constraint_name = col.constraint_name
and con.constraint_type='P'
and col.table_name = 'YourTableName'
3、查询某个表中的外键字段名称、所引用表名、所应用字段名
select distinct(col.column_name),r.table_name,r.column_name
from
user_constraints con,
user_cons_columns col,
(select t2.table_name,t2.column_name,t1.r_constraint_name
from user_constraints t1,user_cons_columns t2
where t1.r_constraint_name=t2.constraint_name
and t1.table_name='YourTableName'
) r
where con.constraint_name=col.constraint_name
and con.r_constraint_name=r.r_constraint_name
and con.table_name='YourTableName'