Chinaunix首页 | 论坛 | 博客
  • 博客访问: 231919
  • 博文数量: 26
  • 博客积分: 1435
  • 博客等级: 上尉
  • 技术积分: 290
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-15 16:11
文章分类

全部博文(26)

文章存档

2014年(1)

2013年(2)

2012年(1)

2011年(1)

2010年(2)

2009年(11)

2008年(3)

2006年(3)

2005年(2)

我的朋友

分类: Oracle

2008-12-19 16:08:25

例如:

在远程数据库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脚本。

阅读(3494) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~