PLS-00103: Encountered the symbol “CREATE” when expecting
If you want to use DDL statement in PL/SQL Blocks then you can do not write directly DDL Statement.
You have to use the Dynamic SQL Syntax for executing the DDL Statement.
Error:
SQL> begin
2 create table test_bkp1 (id number);
3 end
4 /
create table test_bkp1 (id number);
*
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
( begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
Solution:
Donot use DDL directly in PL/SQL blocks. Use the DDL Statements with Dynamic SQL as follows.
BEGIN
EXECUTE IMMEDIATE 'create table TEST_BKP1 (id number, column_value varchar2(100))';
END;
/