The DDL command cannot be executed directly with the database link on the remote database. If it is run, it will cause the error as follows.
ORA-02021: DDL operations are not allowed on a remote database.
The dbms_utility.exec_ddl_statement procedure must be used for this. With this procedure, any DDL command can be executed in the remote database. In this way, all operations can be done from a single point.
Sample use:
1 |
SQL> exec dbms_utility.exec_ddl_statement@DB_LINK('TRUNCATE TABLE USER.TABLO_NAME'); |
In the above example, DB_LINK specifies the database link. After that, the command is executed in parenthesis and single quotes.
Similarly it is also possible to create a table as follows.
1 |
SQL> exec dbms_utility.exec_ddl_statement@DB_LINK('create table t1 (id number)'); |
In this way, it is possible to run DDL commands through the database link in the remote database.