Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Specifying column datatypes in CTAS
Precreate the table with the structure you like and use INSERT /*+ APPEND */
command to populate your table afterwards.
Tanel.
>
>
>
>
> Hi List,
>
> I have stumbled across a problem and I am hoping there is an easy
solution.
> I have to add two columns to an existing table. One of these columns is
> populated with a constant value for all existing records and the other can
> be determined using a simple DECODE on other existing columns.
>
> The table is quite large (~100 million records) and I was hoping to
combine
> the activity with a rebuild into a new tablespace at the same time.
> Therefore, I figure the quickest way to achieve this is a simple "create
> table as select" type statement.
>
> My problem is specifying the datatypes, and in particular the NOT NULL
> state of the newly added columns. Working on Oracle 8.1.7.4 I get an
error
> if I try something like "create table my_dual (the_col varchar2(10) not
> null) as select * from dual" - I cannot specify datatypes when using an
"as
> select..." clause it seems.
>
> I realise I can name the new columns using column aliasing in the select
> clause, but I am struggling to get the length of the data type and the NOT
> NULL attribute set on the new columns.
>
> What is the best way to resolve this problem? Is there some syntax I am
> missing or do I absolutely need to create structure and then insert data?
>
> Thanks in advance,
>
> Mark.
>
>
>
>
>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>> Privileged/Confidential information may be contained in this message.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html -----------------------------------------------------------------Received on Tue Feb 24 2004 - 18:19:39 CST
![]() |
![]() |