简体   繁体   中英

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.

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. For example, if "myfile" is defined as "reports" then the command:

 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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