oracle 如何使用 SQL 命令导入文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8267764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 03:43:36  来源:igfitidea点击:

How do I import file with SQL commands?

oracleimportoracle11g

提问by marxin

I have a simple problem, but I can't find out how to solve it.
I have a file which contains many SQL commands, like this:

我有一个简单的问题,但我不知道如何解决它。
我有一个包含许多 SQL 命令的文件,如下所示:

insert into .. ;
insert into .. ;
...

And now is the question - how do I import it?
I was trying to import script, but it doesn't work, I'm getting:

现在的问题是 - 我如何导入它?
我试图导入脚本,但它不起作用,我得到:

Your export file is not supported

When I'm copying my commands manually, it's works. But I can't copy them all, it will take too long.

当我手动复制我的命令时,它是有效的。但是我不能全部复制它们,这将花费太长时间。

I'm using Oracle DB 11g XE.

我正在使用 Oracle DB 11g XE。

Any solutions?

任何解决方案?

回答by Pablo Santa Cruz

You need a SQL interpreter for Oracle. The one that is bundled with every Oracle client installation is called SQL*Plus. And will do what you need to import a file with SQL commands.

您需要一个用于 Oracle 的 SQL 解释器。与每个 Oracle 客户端安装捆绑在一起的那个称为SQL*Plus。并将执行您需要使用 SQL 命令导入文件的操作。

You login with it to your Oracle server and then run your script. Let's say your Oracle connection is called mydband your schema name is scottand your SQL script is stored in a file called myfile.sql. What you can do is:

您使用它登录到您的 Oracle 服务器,然后运行您的脚本。假设您的 Oracle 连接名为mydb,您的架构名称为scott,您的 SQL 脚本存储在名为myfile.sql的文件中。你可以做的是:

$ sqlplus scott@mydb

To login to oracle (you will be prompted with your password). And then, once you are inside SQL*Plus, you can do:

登录 oracle(系统将提示您输入密码)。然后,一旦您进入SQL*Plus,您就可以执行以下操作:

> @myfile.sql

Done.

完毕。

回答by Vincent Malgrat

Use SQL*Plus or Oracle SQL developer.

使用 SQL*Plus 或Oracle SQL 开发人员

With SQL*Plus:

使用 SQL*Plus:

sqlplus <schema>/<pw> @<your_script.sql>

With SQL Developer, open your script, and then "run as script" (F5I think).

使用 SQL Developer,打开您的脚本,然后“作为脚本运行”(F5我认为)。