在 Oracle 中注册 XML 模式 - 如何摆脱剩余的对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2059272/
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
Registering XML Schemas in Oracle - how to get rid of leftover objects
提问by FrustratedWithFormsDesigner
I tried to register a schema in Oracle the other day to validate an XML document. The code I used was fairly simple:
前几天我试图在 Oracle 中注册一个模式来验证一个 XML 文档。我使用的代码相当简单:
dbms_xmlschema.registerSchema(schemaURL => 'http://www.myCompany.com/schema',
schemaDoc => :schemaCLOB);
At first, everything seemed to work well, as far as validation goes. I noticed though, that there were dozens of new database objects: tables, triggers and types (a few dowsn tables and triggers, but probably many hundreds of types). I tried to delete the schema like this:
起初,就验证而言,一切似乎都运行良好。不过我注意到,有几十个新的数据库对象:表、触发器和类型(一些 dowsn 表和触发器,但可能有数百种类型)。我试图删除这样的架构:
dbms_xmlschema.deleteSchema(schemaURL => 'http://www.myCompany.ca/schema',
delete_option => dbms_xmlschema.DELETE_INVALIDATE);
That de-registered the schema, but all of the objects were left behind.
这取消了模式的注册,但所有对象都被留下了。
I RTFM'd a little too late and discovered that the extra objects were created by leaving default values in the call to registerSchema, so I realized I would have to manually remove the extra objects.
我 RTFM 有点太晚了,发现额外的对象是通过在对 registerSchema 的调用中保留默认值来创建的,所以我意识到我必须手动删除额外的对象。
Now when I try to remove the objects, Oracle tells me they don't exist. I can't select from them and my IDE (PL/SQL Developer) shows them as being invalid (a little red "X" beside them). I also can't find any info on these tables in all_tables
. How do I get rid of these?
现在,当我尝试删除这些对象时,Oracle 告诉我它们不存在。我无法从它们中进行选择,并且我的 IDE(PL/SQL Developer)将它们显示为无效(它们旁边有一个小红色的“X”)。我也无法在all_tables
. 我该如何摆脱这些?
采纳答案by FrustratedWithFormsDesigner
Solution was: restored from previous day's backup. In the future, I'll be setting gentables
and gentypes
to FALSE
ALWAYS, and delete with DELETE_CASCADE_FORCE. Anything doesn't work with that, I'll probably post a new question.
解决方案是:从前一天的备份中恢复。在未来,我会设置gentables
和gentypes
对FALSE
ALWAYS,并与DELETE_CASCADE_FORCE删除。任何东西都不起作用,我可能会发布一个新问题。
回答by Ian Carpenter
I'm probably missing something obvious but looking at the documentationcould you not use the DELETE_CASCADE or DELETE_CASCADE_FORCE options?
我可能遗漏了一些明显的东西,但是查看文档您可以不使用 DELETE_CASCADE 或 DELETE_CASCADE_FORCE 选项吗?
回答by Marco Gralike
Metalink is Oracle's support site (http://support.oracle.com) but you would need a customer support ID(entifier) to enter the protected site.
Metalink 是 Oracle 的支持站点 ( http://support.oracle.com),但您需要一个客户支持 ID(entifier)才能进入受保护站点。
If on 11g use DBMS_XMLSCHEMA.PURGESCHEMA to get rid of the objects. If on 10gRx use
如果在 11g 上使用 DBMS_XMLSCHEMA.PURGESCHEMA 去除对象。如果在 10gRx 上使用
dbms_xmlschema.deleteSchema(schemaURL => 'http://www.myCompany.ca/schema',
delete_option => dbms_xmlschema.DELETE_CASCADE_FORCE);
dbms_xmlschema.deleteSchema(schemaURL => 'http://www.myCompany.ca/schema',
delete_option => dbms_xmlschema.DELETE_CASCADE_FORCE);
or
或者
dbms_xmlschema.deleteSchema('http://www.myCompany.ca/schema',4);
dbms_xmlschema.deleteSchema('http://www.myCompany.ca/schema',4);
If that doesn't help bounce the database after using force delete and try again. If that doesn't help, delete the schema via a delete statement based on user_xml_schemas (last option is not supported).
如果在使用强制删除后这对退回数据库没有帮助,请重试。如果这没有帮助,请通过基于 user_xml_schemas 的删除语句删除架构(不支持最后一个选项)。