Hvis du har SQL-script til at gøre dette, kan du blot tilføje connect-sætning for at skifte bruger som vist nedenfor.
Jeg har test.sql
fil, der indeholder bevillings- og ændringserklæringer. Jeg har to brugere sh
og 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;
Og jeg har simpelthen udført scriptet.
[[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>