首页 文章

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

提问于
浏览
2

我从 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 回答

  • 2

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

    我有 test.sql 文件,其中包含grant和alter语句 . 我有两个用户 shhr .

    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>
    

相关问题