How to call DDL statements from pl/sql?

Answer Posted / kavitha nedigunta

set serveroutput on;
DECLARE
CNT NUMBER;
table_name varchar2(300) := 'testnew';
BEGIN
--EXECUTE IMMEDIATE ('grant create table to user_name');
EXECUTE IMMEDIATE ('create table '||table_name||'(name
varchar2(10))');

SELECT COUNT(*) INTO CNT FROM USER_OBJECTS WHERE OBJECT_NAME = upper(''||table_name||'');

IF cnt > 0 THEN
dbms_output.put_line('Table Created');
END IF;

EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Name is already used by an existing object');
END;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is sap sql?

536


Which is faster view or stored procedure?

505


What are the types of join and explain each?

582


what are the advantages of mysql in comparison to oracle? : Sql dba

529


Do triggers have restrictions on the usage of large datatypes, such as long and long raw?

691






What is the usage of sql functions?

547


What are basic techniques of indexing?

849


What is hibernate and its relation to sql?

594


how many tables will create when we create table, what are they? : Sql dba

545


what are integrity rules?

570


What is a pl/sql block?

595


What is meant by cursor in sql?

548


What are the three pl sql block types?

573


Is it possible to Restore a Dropped Table using Rollback Command in Oracle SQL Plus ?

722


What is a sql*loader control file?

622