我从RATOR_MONITORING
架构运行以下查询,该架构授予RATOR_MONITORING_CONFIGURATION.SMSC_GATEWAY
表到RATOR_MONITORING
架构的引用权限。
GRANT REFERENCES ON "RATOR_MONITORING_CONFIGURATION"."SMSC_GATEWAY" TO "RATOR_MONITORING";
ALTER TABLE "RATOR_MONITORING"."SMSC_GATEWAY_STATUS" ADD CONSTRAINT "SMSC_GATEWAY_STATUS_FK1" FOREIGN KEY ("SMSC_GATEWAY_ID")
REFERENCES "RATOR_MONITORING_CONFIGURATION"."SMSC_GATEWAY" ("ID") ON DELETE CASCADE ENABLE;
当我运行以下查询时,我收到错误:
SQL Error: ORA-01749: you may not GRANT/REVOKE privileges to/from yourself
我还有其他sql语句,我只想从RATOR_MONITOR
模式运行。此sql语句存储在sql文件中。我在sql plus中运行这个sql文件。那么有没有办法使用匿名块或任何其他approch,我可以连接到架构RATOR_MONITORING_CONFIGURATION
架构并授予引用权限,并再次连接到rator_monitor架构并运行alter table语句和其他sql语句。
答案 0 :(得分:2)
如果您有SQL脚本来执行此操作,那么您只需添加connect语句即可切换用户,如下所示。
我有sh
文件,其中包含grant和alter语句。我有两个用户hr
和conn sh/sh@orcl
grant REFERENCES on sh.customers to hr;
conn hr/hr@orcl
ALTER TABLE cust ADD CONSTRAINT fk1 FOREIGN KEY (ID) REFERENCES sh.customers(CUST_ID) ON DELETE CASCADE ENABLE;
。
[oracle@ora12c ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Tue Jan 17 15:19:40 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options
SQL> @test.sql
Connected.
Grant succeeded.
Connected.
Table altered.
SQL>
我只是执行了脚本。
Public Sub New(ByVal Name As String)
'Statements
End Sub