可以通过给用户授予两个角色,每个角色分别授权并设置口令来实现一个用户名两个口令和权限。例如:
SQL> connect system/manager
Connected.
SQL> create role role1 identified by password1;Role created.SQL> create role role2 identified by password2;Role created.SQL> grant select on test.t1 to role1;Grant succeeded.SQL> grant select on test.t2 to role2;Grant succeeded.SQL> CREATE USER user1  PROFILE "DEFAULT" IDENTIFIED BY "aaa" DEFAULT TABLESPACE users TEMPORARY TABLESPACE TEMP QUOTA UNLIMITED ON users QUOTA UNLIMITED ON TEMP ACCOUNT UNLOCK;User created.SQL> grant role1 to user1;Grant succeeded.SQL> grant role2 to user1;Grant succeeded.SQL> GRANT CONNECT TO user1;Grant succeeded.SQL> alter user user1 default role connect;User altered.SQL> connect user1/aaa
Connected.
SQL> select count(*) from test.t1;
select count(*) from test.t1
                          *
ERROR at line 1:
ORA-00942: 表或视图不存在
SQL> set role role1 identified by password1;Role set.SQL> select count(*) from test.t1;  COUNT(*)
----------
     29172SQL> select count(*) from test.t2;
select count(*) from test.t2
                          *
ERROR at line 1:
ORA-00942: 表或视图不存在
SQL> set role role2 identified by password2;Role set.SQL> select count(*) from test.t2;  COUNT(*)
----------
     81036SQL> select count(*) from test.t1;
select count(*) from test.t1
                          *
ERROR at line 1:
ORA-00942: 表或视图不存在