Oracle数据库信息查询

  • 查看当前数据库
select name from V$DATABASE;
select SYS_CONTEXT('USERENV','INSTANCE_NAME') from dual;

image

  • 用户
select username,default_tablespace from user_users;

看当前用户的缺省表空间。

image

select * from user_role_privs;
select * from user_sys_privs;

查看当前用户的权限

image

select username,default_tablespace from user_users;

查看当前用户的角色。

image

select * from session_privs;

显示当前会话所具有的权限。

select * from user_tab_privs;
select * from user_tables;

查看用户下所有的表。

select object_name,object_id from user_objects where instr(object_name,'XXX')>0;

看名称包含XXX字符的表。

select object_name,created from user_objects where object_name=upper('&table_name');

查看某表的创建时间。

image

select sum(bytes)/(1024*1024) as "size(M)" from user_segments where segment_name=upper('&table_name');

查看某表的大小。

image

  • 索引
select index_name,index_type,table_name from user_indexes order by table_name;

查看索引个数和类别。

select * from user_ind_columns where index_name=upper('&index_name');

查看索引被索引的字段。

>select sum(bytes)/(1024*1024) as "size(M)" from user_segments where segment_name=upper('&index_name');

查看索引的大小。

  • 视图
select view_name from user_views;

查看视图的名称。

image

  • 约束条件
select constraint_name, constraint_type,search_condition, r_constraint_name from user_constraints where table_name = upper('&table_name');

查看某表的约束条件。

  • 存储函数和过程
select object_name,status from user_objects where object_type='FUNCTION';

查看函数和过程的状态。

select object_name,status from user_objects where object_type='PROCEDURE';

查看函数和过程的源代码。

  • 查看表结构
desc &table_name;

转载请注明出处:http://www.cnblogs.com/yydcdut/p/3643583.html

原文地址:https://www.cnblogs.com/yydcdut/p/3643583.html