ORA-01749:您不得向自己授予/撤销特权

时间:2017-01-17 08:47:55

标签: sql oracle reference grant

我从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语句。

1 个答案:

答案 0 :(得分:2)

如果您有SQL脚本来执行此操作,那么您只需添加connect语句即可切换用户,如下所示。

我有sh文件,其中包含grant和alter语句。我有两个用户hrconn 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