Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: create table
I created it as a procedure because may be there's a lot
of columns, so you can edit the procedure, and include
the commands to insert the columns.
Create the procedure and then execute it, passing the name of
your table as a parameter
Before execute the procedure, do not forget to set arraysize 1,
as well as set serveroutput on
CREATE OR REPLACE PROCEDURE CR_TAB (P_TABNAME IN VARCHAR2) IS
FL_EXIST VARCHAR2(1);
begin
DBMS_OUTPUT.ENABLE;
SELECT 'N' INTO FL_EXIST FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM ALL_TABLES WHERE TABLE_NAME = P_TABNAME); IF FL_EXIST = 'N' THEN DBMS_OUTPUT.PUT_LINE('CREATE TABLE '||P_TABNAME||' ('); -- here, you include col definitions DBMS_OUTPUT.PUT_LINE('COL_1 VARCHAR2(nn)'); . . DBMS_OUTPUT.PUT_LINE(');');
GOOD LUCK!
In article <8l276n$3sn$1_at_nnrp1.deja.com>,
shuiho_at_my-deja.com wrote:
> Hi everyone,
>
> I would like to do following:
>
> If the table MYTABLE does not exist then
> create table MYTABLE
> end if;
>
> How can I do this in Oracle SQLPLUS script ? Please help me.
> Thank you.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Wed Jul 19 2000 - 00:00:00 CDT