dba_tables : 系统里所有的表的信息,需要DBA权限才能查询
all_tables : 当前用户有权限的表的信息(只要对某个表有任何权限,即可在此视图中看到表的相关信息)
user_tables: 当前用户名下的表的信息
所以以上3个视图中,user_tables的范围最小,all_tables看到的东西稍多一些,而dba_tables看到最多的信息
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
DBA_TABLES describes all relational tables accessible to the DBA user
DBA_TABLES是DBA用户所拥有的或有访问权限的表
ALL_TABLES describes all relational tables accessible to the current user
ALL_TABLES是某一用户所拥有的或有访问权限的表
USER_TABLES describes all relational tables owned by the current user
USER_TABLES是某一用户所拥有的表
故DBA_TABLES >= ALL_TABLES >= USER_TABLES
DBA_ALL_TABLES Description of all object and relational tables in the database
DBA_ALL_TABLES是DBA用户所拥有的或有访问权限的对象和表
ALL_ALL_TABLES Description of all object and relational tables accessible to the user
ALL_ALL_TABLES是某一用户拥有的或有访问权限的对象和表
USER_ALL_TABLES Description of all object and relational tables owned by the user's
USER_ALL_TABLES是某一用户所拥有的对象和表
故DBA_ALL_TABLES >= ALL_ALL_TABLES >= USER_ALL_TABLES
获取表: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='用户名' user_tables的字段包括:table_name,tablespace_name,last_analyzeddba_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等 获取表字段:select * from user_tab_columns where Table_Name='用户表';select * from all_tab_columns where Table_Name='用户表';select * from dba_tab_columns where Table_Name='用户表'; user_tab_columns的字段包括:table_name,column_name,data_type,data_length,data_precision,data_scale,nullable,column_id等 all_tab_columns 字段包括:ower,table_name,column_name,data_type,data_length,data_precision,data_scale,nullable,column_id等 dba_tab_columns字段包括:ower,table_name,column_name,data_type,data_length,data_precision,data_scale,nullable,column_id等 获取表注释:select * from user_tab_commentsuser_tab_comments:table_name,table_type,comments相应的还有dba_tab_comments,all_tab_comments,这两个比user_tab_comments多了ower列。 获取字段注释:select * from user_col_commentsuser_col_comments:table_name,column_name,comments相应的还有dba_col_comments,all_col_comments,这两个比user_col_comments多了ower列。
本文详细介绍了在数据库管理系统中使用不同的视图(dbas_tables、all_tables、user_tables)来查询表信息的方法,包括如何获取表名、字段、注释等关键信息,并提供了SQL查询语句实例。
2364

被折叠的 条评论
为什么被折叠?



