これを行うSQLスクリプトがある場合は、以下に示すように、connectステートメントを追加してユーザーを切り替えることができます。
test.sqlがあります 付与ステートメントと変更ステートメントを含むファイル。 2人のユーザーshがいます およびhr 。
conn sh/example@sqldat.com
grant REFERENCES on sh.customers to hr;
conn hr/example@sqldat.com
ALTER TABLE cust ADD CONSTRAINT fk1 FOREIGN KEY (ID) REFERENCES sh.customers(CUST_ID) ON DELETE CASCADE ENABLE;
そして、私は単にスクリプトを実行しました。
[example@sqldat.com ~]$ 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>