oracle如何查询表中所有字段
oracle查询表中所有字段
查询表中所有字段
-- user_tab_columns 自定义的字段 SELECT column_name FROM user_tab_columns where table_name = upper('表名') -- user_tab_cols 包含oracle创建的隐藏字段 SELECT column_name FROM user_tab_cols where table_name = upper('表名')
将表所有列名查出,并拼成字符串
select Listagg(column_name, ',') WITHIN GROUP(ORDER BY column_name) from user_tab_columns where table_name = upper('表名') --不想查询的字段名 and column_name not in ('字段名','字段名');
oracle查看所有表信息和字段信息以及注释信息等
1、获取表
select table_name from user_tables; //当前用户拥有的表 select table_name from all_tables; //所有用户的表 select table_name from dba_tables; //包括系统表 select table_name from dba_tables where owner='用户名' ALL_OBJECTS describes all objects accessible to the current user. 描述当前用户有访问权限的所有对象 DBA_OBJECTS describes all objects in the database. 描述了数据库中的所有对象 USER_OBJECTS describes all objects owned by the current user. 描述了当前用户所拥有的所有对象
- user_tables: TABLE_NAME,TABLESPACE_NAME,LAST_ANALYZED等
- dba_tables: ower,table_name,tablespace_name,last_analyzed等
- all_tables: ower,table_name,tablespace_name,last_analyzed等
- all_objects: ower,object_name,subobject_name,object_id,created,last_ddl_time,timestamp,status等
2、获取表字段
user_tab_comments;表注释 select * from user_tab_comments user_tab_comments:table_name,table_type,comments
相应的还有dba_tab_comments,all_tab_comments,这两个比user_tab_comments多了ower列。
3、获取表注释
user_tab_comments;表注释 select * from user_tab_comments user_tab_comments:table_name,table_type,comments
相应的还有dba_tab_comments,all_tab_comments,这两个比user_tab_comments多了ower列。
4、获取字段注释
select * from user_col_comments user_col_comments:table_name,column_name,comments
相应的还有dba_col_comments,all_col_comments,这两个比user_col_comments多了ower列。
- user_col_comments;表字段注释(列注释)
- USER_COL_COMMENTS 视图显示已经为表中的列输入的注释。
这些注释通过comment命令添加到数据库中。
USER_COL_COMMENTS 视图包含3 列:
- Table_Name 表名或视图名
- Column_Name 列名
- Comments 已经为该列输入的注释
5、查表字段注释事例
查看JH表中字段的注释:
select table_name,column_name,comments from user_col_comments where table_name=‘JH';
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
Oracle密码过期如何取消密码180天限制及密码180天过期,账号锁住的问题
这篇文章主要介绍了Oracle密码过期如何取消密码180天限制及密码180天过期,账号锁住的问题,需要的朋友可以参考下2018-12-12Oracle 11g+windows 环境下Ecology7系统安装过程
这篇文章主要介绍了Oracle 11g+windows 环境下Ecology7系统安装,安装步骤是以管理员模式运行Oracle setup.exe文件,根据提示安装Oracle,创建数据库,注意修改连接数,本文给大家详细讲解,需要的朋友可以参考下2022-10-10
最新评论