查询oracle中所有用户信息
来源:互联网 发布:苹果换彩铃用什么软件 编辑:程序博客网 时间:2024/05/19 17:59
1.查看所有用户:
select * from dba_users;
select * from all_users;
select * from user_users;
2.查看用户或角色系统权限(直接赋值给用户或角色的系统权限):
select * from dba_sys_privs;
select * from user_sys_privs; (查看当前用户所拥有的权限)
3.查看角色(只能查看登陆用户拥有的角色)所包含的权限
sql>select * from role_sys_privs;
4.查看用户对象权限:
select * from dba_tab_privs;
select * from all_tab_privs;
select * from user_tab_privs;
5.查看所有角色:
select * from dba_roles;
6.查看用户或角色所拥有的角色:
select * from dba_role_privs;
select * from user_role_privs;
7.查看哪些用户有sysdba或sysoper系统权限(查询时需要相应权限)
select * from V$PWFILE_USERS
8.SqlPlus中查看一个用户所拥有权限
SQL>select * from dba_sys_privs where grantee='username';
其中的username即用户名要大写才行。
比如:
SQL>select * from dba_sys_privs where grantee='TOM';
9、Oracle删除指定用户所有表的方法
select 'Drop table '||table_name||';' from all_tables
where owner='要删除的用户名(注意要大写)';
10、删除用户
drop user user_name cascade;
如:drop user SMCHANNEL CASCADE
11、获取当前用户下所有的表:select table_name from user_tables;
12、删除某用户下所有的表数据: select 'truncate table ' || table_name from user_tables;
13、禁止外键
ORACLE数据库中的外键约束名都在表user_constraints中可以查到。其中constraint_type='R'表示是外键约束。
启用外键约束的命令为:alter table table_name enable constraint constraint_name
禁用外键约束的命令为:alter table table_name disable constraint constraint_name
然后再用SQL查出数据库中所以外键的约束名:
select 'alter table '||table_name||' enable constraint '||constraint_name||';' from user_constraints where constraint_type='R'
select 'alter table '||table_name||' disable constraint '||constraint_name||';' from user_constraints where constraint_type='R'
14、ORACLE禁用/启用外键和触发器
--启用脚本
SET SERVEROUTPUT ON SIZE 1000000
BEGIN
for c in (select 'ALTER TABLE '||TABLE_NAME||' ENABLE CONSTRAINT '||constraint_name||' ' as v_sql from user_constraints where CONSTRAINT_TYPE='R') loop
DBMS_OUTPUT.PUT_LINE(C.V_SQL);
begin
EXECUTE IMMEDIATE c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;
for c in (select 'ALTER TABLE '||TNAME||' ENABLE ALL TRIGGERS ' AS v_sql from tab where tabtype='TABLE') loop
dbms_output.put_line(c.v_sql);
begin
execute immediate c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;
end;
/
commit;
--禁用脚本
SET SERVEROUTPUT ON SIZE 1000000
BEGIN
for c in (select 'ALTER TABLE '||TABLE_NAME||' DISABLE CONSTRAINT '||constraint_name||' ' as v_sql from user_constraints where CONSTRAINT_TYPE='R') loop
DBMS_OUTPUT.PUT_LINE(C.V_SQL);
begin
EXECUTE IMMEDIATE c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;
for c in (select 'ALTER TABLE '||TNAME||' DISABLE ALL TRIGGERS ' AS v_sql from tab where tabtype='TABLE') loop
dbms_output.put_line(c.v_sql);
begin
execute immediate c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;
end;
/
commit;
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 查询oracle中所有用户信息
- 一段时间以来,我在思索一个问题:如何让别人知道你的产品?
- sql server 创建分区表
- 简单总结Service-与Activity生命周期
- source insight高速定位文件
- shell脚本监视进程
- 查询oracle中所有用户信息
- android 函数可变参数
- Duck typing
- java.sql.SQLException:Value ’0000-00-00′ can not be represented as java.sql.Date
- [Java基础要义] Java语言中Object对象的hashCode()取值的底层算法是怎样实现的?
- 仿Openstack的WSGI接口及RESTul服务实现(python)(转)
- enq: TX - index contention
- Hack Like a Pro: How to Kill and Disable Antivirus Software on a Remote PC
- Sicily 1176 Two Ends