日期:2014-05-16  浏览次数:20419 次

Oracle帐号基本管理
1. Oracle安装完成后的用户名和密码
sys/change_on_install
system/manager
scott/tiger
sysman/oem_temp
internal/oracle

2.修改用户的密码
SQL> conn sys/change_on_install as sysdba
Connected.
SQL> alter user sys identified by ******;
User altered.

3.为用户解锁
SQL> conn scott/tiger
ERROR:
ORA-28000: the account is locked
Warning: You are no longer connected to ORACLE.
SQL>conn sys/change_on_install as sysdba
Connected.
SQL> alter user scott account unlock;
User altered.

锁定用户:
SQL> alter user scott account lock;

4.查看所有用户:
  select * from dba_users;
  select * from all_users;
  select * from user_users;

5.查看用户或角色系统权限:
  select * from dba_sys_privs;
  select * from user_sys_privs;

6.查看用户对象权限:
  select * from dba_tab_privs;
  select * from all_tab_privs;
  select * from user_tab_privs;

7..查看所有角色:
  select * from dba_roles;

8.查看用户或角色所拥有的角色:
  select * from dba_role_privs;
  select * from user_role_privs;

9.创建用户
SQL> create user kevin identified by password
2 default tablespace users
3 temporary tablespace temp
4 quota 10M on users;
User created.
SQL> conn kevin/password
ERROR:
ORA-01045: user KEVIN lacks CREATE SESSION privilege; logon denied
SQL> grant create session to kevin;  //授权用户可以连接数据库
Grant succeeded.

10.授权用户connect和resource角色
SQL> grant connect to kevin; 
Grant succeeded.
SQL> grant resource to kevin;
Grant succeeded.
SQL> grant connect,resource to kevin;
Grant succeeded.

11.查看connect和resource的权限
SQL> select * from dba_sys_privs where grantee='CONNECT';
GRANTEE                        PRIVILEGE                                ADM
------------------------------ ---------------------------------------- ---
CONNECT                        ALTER SESSION                            NO
CONNECT                        CREATE CLUSTER                           NO
CONNECT                        CREATE DATABASE LINK                     NO
CONNECT                        CREATE SEQUENCE                          NO
CONNECT                        CREATE SESSION                           NO
CONNECT