oracle用户远程建表、用户、授权、导入数据

来源:互联网 发布:华宇软件待遇 编辑:程序博客网 时间:2024/06/05 07:49

在远程数据库uptest上建立用户test,表空间test,临时表空间testtemp,并授权

一、创建建表脚本(test.sql),内容如下

建表空间“test”

create tablespace test datafile '/oracle/u02/uptest/uptest/test.dbf'  size 5M;

建临时表空间“testtemp”

create TEMPORARY tablespace testtemp tempfile '/oracle/u02/uptest/uptest/testtemp.dbf'size 5M;

建用户“test”,密码为“oracle”,指定表空间“test”,临时表空间“testtemp”

create user test identified by oracle default tablespace test temporary tablespace testtemp;

为用户“test”授权" connect,resource,dba,create any table,select any dictionary "

grant  connect,resource,dba,create any table,select any dictionary to test;

 

二、建立shell脚本(test.sh),内容如下

#!/bin/sh

sqlplus /nolog  <

spool /home/oracle/test.log    将sqlplus屏幕输出到文件“test.log”

connect system/oracle@uptest  连接远端orale服务器“uptest”

@/home/oracle/test.sql        执行建表、建用户、授权脚本“test.sql”

host imp userid=system/oracle@uptest fromuser=xianmis touser=test  file=/home/oracle/test.dmp log=/home/oracle/imp.log     执行操作系统命令,导入表“test.dmp”

spool off                    关闭spool

EOF

 

将test.sql和test.dmp文件放入脚本中指定的目录,

为test.sh脚本加上执行权限:#chmod +755 test.sh

用oracle用户运行test.sh脚本。
0 0