Oracle 用户权限

来源:互联网 发布:银客网网络理财 编辑:程序博客网 时间:2024/05/22 08:13
--创建用户panda,密码为passwords:create user panda identified by passwords;--系统权限:grant create session to panda; --拥有该权限,用户才可以登录数据库grant create table to panda; --授予创建表的权限grant unlimited tablespace to panda; --授予不受限制的使用表空间的权限--回收权限:revoke create session from panda;revoke create table from panda;revoke unlimited tablespace from panda;--对象权限:grant select on mytable to panda; --授予用户panda对mytable表查询的权限grant insert on mytable to panda; --授予用户panda对mytable表插入的权限grant all on mytable to panda; --授予用户panda对mytable表所有的操作权限--对象权限可以精确的控制到列(只能针对插入和更新):--注意: 查询和删除不能控制到列,只能是整行.grant update(name) on mytable to panda1; --授予panda1可以对mytable表更新name字段的权限grant insert(id) on mytable to panda1; --授予panda1可以对mytable表插入id字段的权限--回收权限:revoke select on mytable from panda;revoke insert on mytable from panda;revoke all on mytable from panda;--授予[所有用户]都拥有某个权限(public指所有用户):grant create session to public;grant create any table to public;--查看当前用户拥有哪些系统权限:select * from user_sys_privs;--查看当前用户拥有哪些对象权限:select * from user_tab_privs;--如果对表的对象权限控制精确到列,那么查询权限时,用user_col_privs(column)select * from user_col_privs;

对象的传递

--权限的传递grant alter any table to panda1 with admin option;grant select on mytable to panda1 with grant option;--角色create role myrole; --创建角色grant create session to myrole; --给角色分配权限grant create table to myrole; --给角色分配权限grant myrole to zhangsan; --将角色赋予用户drop role myrole; --删除角色create table --可以给自己创建表[alter table(无此权限)][drop table (无此权限)]create any table --可以给任意用户创建表alter any table --修改任意用户的表drop any table --删除任意用户的表--注意: 有些系统角色权限过大,不可以将其赋予角色,只能赋予用户--表是属于某一个用户的;角色不属于某个用户,大家共用的.grant unlimited tablespace to myrole;grant unlimited tablespace to myrole*第 1 行出现错误:ORA-01931: 无法将 UNLIMITED TABLESPACE 授予角色

其他

--创建用户create user 用户名identified by 密码default tablespace 表空间temporary tablespace 表空间quota 整数 K|M|Limited on 表空间--例子create user UserName identified by userPwd default tablespace users temporary tablespace temp quota 50M on users--限制用户--用户加锁alter user UserName account lock;--用户解锁alter user UserName account unlock;--用户口令即刻失效alter user UserName password expire;--删除用户及用户的所有对象drop user UserName cascade;
=======================================================================

密码忘记怎么办?

1.   普通用户密码忘记

用sys用户更改普通用户的密码:

SQL> alteruser panda identified by passwords;

用户已更改。

2.   Sys管理员密码忘记

到D:\oracle\product\10.2.0\db_1\database目录下, 将PWDorcl.ora文件备份, 然后删除该文件

执行命令: C:\Users\pansanday>orapwd file=D:\oracle\product\10.2.0\db_1\database\PWDorcl.ora password=admin entries=5 force=y

这默认是给sys用户重置密码的; entries是该密码文件中最大特权用户允许数量;force是是否覆盖原文件

 

查看该密码文件中特权用户列表

SQL> select * from v$pwfile_users;


USERNAME                       SYSDB SYSOP

----------------------------------- -----

SYS                            TRUE TRUE

0 0
原创粉丝点击