使用SQL查看ORACLE和MYSQL数据库中表信息和表字段信息

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hellogbaby/article/details/82689621

***********************ORACLE******************************************************
1、查看数据表信息(使用oracle数据库系统视图USER_TAB_COLUMNS)
sql:
select * from USER_TAB_COLUMNS where TABLE_NAME = #tablename(表名) order by column_id
查询出来的数据列,DATA_TYPE 是表字段的类型,DATA_LENGTH是字段长度
2、查看数据表字段的注释(使用oracle数据库系统视图USER_COL_COMMENTS)
sql:
select * from USER_COL_COMMENTS where TABLE_NAME =#tablename(表名)
查询出来的数据列,COMMENTS就是字段对应的注释

***********************MYSQL****************************************************
1、查看数据表信息(使用information_schema)
sql:
select * from information_schema.columns where table_schema = ‘库名’ and table_name = ‘表名’;

2、查看数据表字段的注释(使用information_schema)
sql:
select column_name, column_comment from information_schema.columns where table_schema =’db’ and table_name = ‘tablename’ ;

猜你喜欢

转载自blog.csdn.net/hellogbaby/article/details/82689621
今日推荐