以user1登录授权: select 'grant select on ' || table_name || ' to user2;' from user_tables;将查出来的语句copy至执行窗口运行;对于将user3的数据复制到user2的操作同user1复制到user2。步骤已经很具体了,你照着操作就行了。
--脚本main.txt --以user1登录连接数据库,并生成授权脚本; conn user1/password@service_name; set heading off; set feedback off; spool c:\grant.txt; select 'grant select on ' || table_name || ' to user2;' from user_tables; spool off; --运行授权脚本; @c:\grant.txt; --生成插入表数据脚本; spool c:\instab.txt; select 'insert into ' || table_name || ' select * from user1.' || table_name || ';' from user_tables; spool off; --以user2登录运行插入数据脚本; conn user2/password@service_name; @c:\instab.txt; set heading on; set feedback on;将以上脚本保存为c:\main.txt; 在pl/sql的command windows运行main.txt: sql>@c:\main.txt; 或者直接粘贴以上脚本至pl/sql的command windows运行也行.
上面的脚本就是将user1下所有的表数据复制到user2下,你还想得到什么结果呢
应该是 select 'insert into ' || USER2.table_name || ' select * from user1.' || table_name || 谢谢了~
select c1,c2 from user2.tb
grant select on t2 to user1;
select c1,c2 from user2.tb这个不行啊
Select * From User2.TB他们的表不会超过20个吧???
或者说USER3登陆,怎么把把USER1的A表的数据导到USER2的A表内?
我指的是在SQL PLUS下的语句 啊~
select 'insert into ' || table_name || ' select * from user1.' || table_name || ';'
from user_tables;将查出来的这些语句copy至执行窗口运行.
但是前提是user2用户能查询user1的表数据.
要是USER3的状态下,怎么复制到USER2下?
select 'grant select on ' || table_name || ' to user2;' from user_tables;将查出来的语句copy至执行窗口运行;对于将user3的数据复制到user2的操作同user1复制到user2。步骤已经很具体了,你照着操作就行了。
--以user1登录连接数据库,并生成授权脚本;
conn user1/password@service_name;
set heading off;
set feedback off;
spool c:\grant.txt;
select 'grant select on ' || table_name || ' to user2;' from user_tables;
spool off;
--运行授权脚本;
@c:\grant.txt;
--生成插入表数据脚本;
spool c:\instab.txt;
select 'insert into ' || table_name || ' select * from user1.' || table_name || ';'
from user_tables;
spool off;
--以user2登录运行插入数据脚本;
conn user2/password@service_name;
@c:\instab.txt;
set heading on;
set feedback on;将以上脚本保存为c:\main.txt;
在pl/sql的command windows运行main.txt:
sql>@c:\main.txt;
或者直接粘贴以上脚本至pl/sql的command windows运行也行.
select 'insert into ' || USER2.table_name || ' select * from user1.' || table_name || 谢谢了~