[英]Import oracle dump file into Oracle using cx_Oracle
I am trying to import dump file into Oracle using cx_Oracle. 我正在尝试使用cx_Oracle将转储文件导入Oracle。 I am able to execute command by command.
我能够按命令执行命令。 Can any one suggest how to do this?
有人可以建议如何做吗?
I'm currently using: 我目前正在使用:
imp servicely/tiger@ubuntu file=/home/hemalatha/hemalatha_data/test_data/oracle/schema_only.sql full=y.
But, I'm getting the error: IMP-00037: Character set marker unknown 但是,我遇到了错误: IMP-00037:字符集标记未知
I think you are confused about what you actually have. 我认为您对自己的实际状况感到困惑。
You say 你说
I am able to execute command by command
我能够按命令执行命令
and also your supposed import file has a .sql
extension. 并且您假定的导入文件具有
.sql
扩展名。 I think you have a script full of SQL statements. 我认为您有一个充满SQL语句的脚本。 You do not have an export file, which is a binary file generated by
exp
or expdp
. 您没有导出文件,该文件是由
exp
或expdp
生成的二进制文件。 imp
and impdp
are used to import the files generated by exp
and expdp
respectively. imp
和impdp
用于分别导入exp
和expdp
生成的文件。 They will act confused if you give them a SQL script to run. 如果您给他们一个SQL脚本来运行它们,他们会感到困惑。
If you have a SQL script to run against the database, use SQL*Plus. 如果您有一个针对数据库运行的SQL脚本,请使用SQL * Plus。 Here's a simple SQL*Plus script which doesn't do much:
这是一个简单的SQL * Plus脚本,作用不大:
PROMPT Hello, we are in SQL*Plus
SELECT * FROM DUAL;
Here's a simple Python script to run this script in SQL*Plus and display the output: 这是一个简单的Python脚本,可在SQL * Plus中运行此脚本并显示输出:
import subprocess
script = subprocess.Popen(["sqlplus", "-L", "user/password", "@script.sql"],
stderr=subprocess.STDOUT, stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
script.stdin.close() # Force SQL*Plus to exit after reading script.
for line in script.stdout:
print line.rstrip()
Note that we need to connect to SQL*Plus's input and close it, as otherwise SQL*Plus will not exit and the script will hang. 请注意,我们需要连接到SQL * Plus的输入并关闭它,否则SQL * Plus不会退出并且脚本将挂起。
When I run this, I get the following output: 运行此命令时,将得到以下输出:
SQL*Plus: Release 11.2.0.2.0 Production on Mon May 26 14:22:34 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
Hello, we are in SQL*Plus
D
-
X
SQL> Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.