简体   繁体   English

如何使用替换删除属于 sys 中模式用户的表 Oracle sql

[英]how to drop a table that belong to a schema user in sys using substitution Oracle sql

I tried to drop a table tableA owned by schema tom in sys.我试图删除 sys 中模式 tom 拥有的表 tableA。

I was able to achieve that with the statement我能够通过声明实现这一目标

drop table tom.tableA

Not sure how to use substitution.不确定如何使用替换。 Not working with the following statements.不适用于以下语句。

define schema='tom'
drop table &schema.tableA

From the "Using Substitution Variables" documentation :来自“使用替代变量”文档

If you want to append a period immediately after a substitution variable name, then use two periods together.如果要 append 紧跟在替换变量名之后的一个句点,则将两个句点一起使用。 For example, if "myfile" is defined as "reports" then the command:例如,如果“myfile”被定义为“reports”,那么命令:

 SQL> spool &myfile..log

is the same as:是相同的:

 SQL> spool reports.log

In your case, you need two periods and also to remove the string literal quotes around the schema name:在您的情况下,您需要两个句点,还需要删除架构名称周围的字符串文字引号:

DEFINE schema=tom
DROP TABLE &schema..tableA

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM