赋予脚本:
select 'grant select on ' || tname || ' to user1 ; ' from scott.tab;
SQL> CONN /as sysdba
已连接。
SQL> create tablespace user1;
表空间已创建。
SQL> create user user1 identified by user1 default tablespace user1;
用户已创建
SQL> grant connect,resource to user1;
授权成功。
SQL> conn user1/user1
已连接。
SQL> create table a as select * from scott.emp;
create table a as select * from scott.emp
*
ERROR 位于第 1 行:
ORA-00942: 表或视图不存在
赋予脚本:
SQL> select 'grant select on ' || tname || ' to user1 ; ' from scott.tab;
SQL> create table a as select * from scott.emp;
表已创建。
SQL> select TABLESPACE_NAME from all_tables where table_name='a';
未选定行
SQL> select TABLESPACE_NAME from all_tables where table_name='A';
TABLESPACE_NAME
------------------------------
USER1
SQL> create table b as select * from scott.dept;
表已创建。
SQL> select * from b;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> select TABLESPACE_NAME from all_tables where table_name='B';
TABLESPACE_NAME
------------------------------
USER1
SQL> create table c as select * from scott.salgrade;
表已创建。
SQL> select * from c;
GRADE LOSAL HISAL
---------- ---------- ----------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
SQL> select tablespace_name from all_tables where table_name='C';
TABLESPACE_NAME
------------------------------
USER1
SQL> create tablespace user2;
create tablespace user2
*
ERROR 位于第 1 行:
ORA-01031: 权限不足
SQL> conn /as sysdba
已连接。
SQL> create tablespace user2;
表空间已创建。
SQL> alter table user1.a move tablespace user2;
表已更改。
SQL> select tablespace_name from all_table where table_name='A';
select tablespace_name from all_table where table_name='A'
*
ERROR 位于第 1 行:
ORA-00942: 表或视图不存在
SQL> show user
USER 为"SYS"
SQL> conn user1/user1
已连接。
SQL> l
1* select tablespace_name from all_table where table_name='A'
SQL> /
select tablespace_name from all_table where table_name='A'
*
ERROR 位于第 1 行:
ORA-00942: 表或视图不存在
SQL> select tablespace_name from all_tables where table_name='A';
TABLESPACE_NAME
------------------------------
USER2
SQL> show user
USER 为"USER1"
SQL> alter table b move tablespace user2;
表已更改。
SQL> show user
USER 为"USER1"
SQL> select tablespace_name from all_tables where table_name='B';
TABLESPACE_NAME
------------------------------
USER2
SQL> select tablespace_name from all_tables where table_name='C';
TABLESPACE_NAME
------------------------------
USER1
SQL> select tablespace_name from all_tables where table_name in ('A','B','C');
TABLESPACE_NAME
------------------------------
USER2
USER2
USER1
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/11977332/viewspace-402156/ ,如需转载,请注明出处,否则将追究法律责任。