如何编译 Oracle SQL 脚本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6279011/
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
How do I compile Oracle SQL scripts?
提问by Amir
I have a series of SQL files, and I want to compile all of them. If do them manually by using benthic software, it takes a long time. I tried using TOAD, but I don't like to use cracked software. Can you help me execute a SQL file? I want to write a program to do some things for me.
我有一系列 SQL 文件,我想编译所有这些文件。如果使用底栖软件手动进行,则需要很长时间。我尝试使用TOAD,但我不喜欢使用破解软件。你能帮我执行一个 SQL 文件吗?我想写一个程序来为我做一些事情。
From sql/plus I tried to create batch file but in some of my sql file developer used "/" and ";" so it caused sql/plus suddenly stopping the compilation. Please advise or recommend free software to help.
从 sql/plus 我尝试创建批处理文件,但在我的一些 sql 文件中,开发人员使用了“/”和“;” 所以它导致sql/plus突然停止编译。请建议或推荐免费软件以提供帮助。
"I want apply the sql package , function and if they are invalid compile them again"
“我想应用 sql 包,函数,如果它们无效,则再次编译它们”
I am using oracle 10g.
我正在使用 oracle 10g。
Thanks
谢谢
回答by Peter Lang
If you search for something like TOAD, try SQL Developer, a free tool from Oracle.
If you want to recompile existing source in your database, you can use
dbms_utility.compile_schema
.If you try to install several files in a batch, SQL*Plusshould work for you. Make sure that your files have the right format.
如果您搜索类似 TOAD 的内容,请尝试SQL Developer,这是 Oracle 的一个免费工具。
如果要重新编译数据库中的现有源代码,可以使用
dbms_utility.compile_schema
.如果您尝试批量安装多个文件,SQL*Plus应该适合您。确保您的文件具有正确的格式。
回答by Gary Myers
"in some of my sql file developer used "/" and ";" "
"在我的一些 sql 文件中,开发人员使用了 "/" 和 ";" "
You need to consistently use these to have any hope of using a tool to deploy. You don't want to have to use a GUI to deploy, so SQL*Plus is the standard to aim for. A good Oracle GUI should be able to run a SQL*Plus deployment script.
您需要始终如一地使用这些,才有希望使用工具进行部署。您不希望必须使用 GUI 进行部署,因此 SQL*Plus 是目标标准。一个好的 Oracle GUI 应该能够运行 SQL*Plus 部署脚本。
I generally start with SET DEFINE OFF otherwise unexpected ampersands (&) cause issues. Do some basic grepping - any script with a CREATE PACKAGE, CREATE PROCEDURE, CREATE TRIGGER or CREATE TYPE (including CREATE OR REPLACE) should have a the "/" to execute that statement. If they don't, fix them.
我通常从 SET DEFINE OFF 开始,否则意外的与符号 (&) 会导致问题。做一些基本的 grepping - 任何带有 CREATE PACKAGE、CREATE PROCEDURE、CREATE TRIGGER 或 CREATE TYPE(包括 CREATE OR REPLACE)的脚本都应该有一个“/”来执行该语句。如果没有,请修复它们。
For a first run though, I'd take them in batches of 10, until I was sure that they executed correctly. I wouldn't worry about compilation errors as long as they load. Afterwards, you can do a recompile of any invalid objects in the schema.
不过,对于第一次运行,我会分批使用它们,每批 10 个,直到我确定它们执行正确为止。只要它们加载,我就不会担心编译错误。之后,您可以重新编译架构中的任何无效对象。
Then check USER_ERRORS to see what is still broken.
然后检查 USER_ERRORS 以查看仍然损坏的内容。
回答by Jordan Parmer
It sounds like you need to run a large sql script. Correct? Sql/Plus should work, but if you want a free IDE, I recommend SQL Developer. It isn't perfect, but it is one of the better free solutions.
听起来您需要运行一个大型 sql 脚本。正确的?Sql/Plus 应该可以工作,但如果你想要一个免费的 IDE,我推荐 SQL Developer。它并不完美,但它是更好的免费解决方案之一。