Re: Creating a table in Oracle DB if it does not exist, using SQL

From: rob <rob_at_dsdelft.nl>
Date: Mon, 13 Sep 2004 17:12:56 +0200
Message-ID: <ci4dds$3op$1_at_news.tudelft.nl>


> If someone can take time to write a running sample and send me, I
> would be Grateful.
>
> Thanks,
> Chaitanya.

Something like this?
=== create_test123.sql ===
DECLARE
   c_table_name varchar2(50) := upper('test123');    cursor c1 is
   select table_name
   from user_tables
   where table_name = c_table_name;
BEGIN
   open c1;
   fetch c1 into v_table_name;
   if c1%NOTFOUND
   then

      execute immediate 'create table test123 (n number
                                              ,b varchar2(20)) ' ;
   end if;
   close c1;
END;
/
  • end create_test123.sql ===
Received on Mon Sep 13 2004 - 17:12:56 CEST

Original text of this message