Se você tiver um script SQL para fazer isso, basta adicionar a instrução connect para alternar o usuário, conforme mostrado abaixo.
Eu tenho
test.sql
arquivo que contém as instruções grant e alter. Eu tenho dois usuários sh
e hr
. conn sh/[email protected]
grant REFERENCES on sh.customers to hr;
conn hr/[email protected]
ALTER TABLE cust ADD CONSTRAINT fk1 FOREIGN KEY (ID) REFERENCES sh.customers(CUST_ID) ON DELETE CASCADE ENABLE;
E eu simplesmente executei o script.
[[email protected] ~]$ 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>