Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: create table with null value
On Thu, 20 Feb 2003 17:26:25 +0100, "Séb" <spribetich_at_auchan.com>
wrote:
>I explain.
>I have a table toto with 2 columns col1, col2.
>I want to create a table toto2 (col1, col2, col3)
>And then insert into toto2 select col1, col2, null from toto.
>
>I want to insert the values at the creation of the table such as :
>create table toto2 as select col1, col2, null from toto.
>
>How it is possible ??
Hi Seb,
The ugly ways first :
create table foo1 (col1 number(10),col2 varchar2(10));
/* Insert 1 M rows in foo1 here */
and then
create table foo2 as (select col1,col2, col2 as col3 from foo1);
or even
create table foo2 as (select col1,col2, 1 as col3 from foo1);
(In this case, col3 gets datatype NUMBER)
Next, the nice and clean way :
Gt full control of the datatype once and for all :
create table foo1 (col1 number(10),col2 varchar2(10)); /* Insert 1 M rows in foo1 here */
THEN create table mytype ( col number(5));
/* Example is number(5), could be anything */
and finally
create table foo2 as ( select col1,col2,mytype.col as col3 from
foo1,mytype
where foo1.COL1 = mytype.col(+));
And you are done.
-Kenneth Koenraadt Received on Thu Feb 20 2003 - 11:47:15 CST