An example of code using native dynamic SQL : Dynamic SQL statement « PL SQL Statements « Oracle PL/SQL Tutorial






SQL> DECLARE
  2    tableName VARCHAR2(30):='temp';
  3    sqlString VARCHAR2(150);
  4  BEGIN
  5    sqlString :='create table '||tableName||'(col1 NUMBER NOT NULL)';
  6    EXECUTE IMMEDIATE sqlString;
  7  END;
  8  /

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL> drop table temp;

Table dropped.








22.22.Dynamic SQL statement
22.22.1.Dynamic DDL
22.22.2.Dynamic DQL with DBMS_SQL package
22.22.3.Table row counter
22.22.4.An example of code using native dynamic SQL
22.22.5.Create dynamic table
22.22.6.Dynamic PL/SQL