Can DDL be used in PL SQL?
Consequently, can we use DDL in procedure?
DDL statements are not allowed in Procedures (PLSQL BLOCK) PL/SQL objects are precompiled. On the other hand, DDL (Data Definition Language) statements like CREATE, DROP, ALTER commands and DCL (Data Control Language) statements like GRANT, REVOKE can change the dependencies during the execution of the program.
Similarly, you may ask, can we use DDL in function in Oracle?
No DDL allowed: A function called from inside a SQL statement is restricted against DDL because DDL issues an implicit commit. You cannot issue any DDL statements from within a PL/SQL function. Restrictions against constraints: You cannot use a function in the check constraint of a create table DDL statement.
DDL commands are not allowed as PL/SQL constructs in PL/SQL blocks. Using DBMS_SQL or EXECUTE IMMEDIATE, we can execute create table, drop, alter, analyze, truncate and other DDL's too. PL/SQL PROCEDURE successfully completed.