Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Create table question
peteg_at_garlic.com wrote:
: I need to create and populate a table using a select statement where
: one of the columns is initially to be populated with the value 'OK'.
: However, this creates a char type, but I need it to be a varchar2
: because, subsequently, I will be modifying the value within that
: column.
: For example, when I try to create a table like this:
: create table test as select sysdate ADate, 'OK' AFlag from dual
SQL> create table try as select decode(dummy,'Y',rpad(dummy,55),'OK') aflag from dual ;
Table created.
SQL> desc try
Name Null? Type ----------------------------- -------- -------------------- AFLAG VARCHAR2(55)
SQL> select * from try ;
AFLAG
1 row selected.
Note the length from the rpad, and the type from dummy, and the value from the literal 'OK'.
There is probably a prettier way if you play with some other functions, but I hope you get the idea.
-- This space not for rent.Received on Thu Jan 20 2005 - 14:02:50 CST