Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to change the datatype of the View column?
On 2005-11-16, nhcox_at_o2.pl <nhcox_at_o2.pl> wrote:
> CREATE OR REPLACE VIEW MYUSER.CLASS_VALUE
> (
> TARIFF_CLASS,
> DESCRIPTION
> )
> AS
> select substr(MYUSER.XXX_DEFAULTS.VALUE,1,3) as TARIFF_CLASS,
> MYUSER.XXX_DEFAULTS.DESCRIPTION
> from MYUSER.XXX_DEFAULTS
>
> As one can see, the TARIFF_CLASS should be varchar2(3). However,
> XXX_DEFAULTS.VALUE is vachar2(9) and therefore it is also vachar2(9).
>
> How to change the type to varchar2(3)?
First: This is not the case with Oracle 10g:
RENE> create table xyz (a varchar2(9));
Table created.
RENE> create view v1 as select substr(a,1,3) a from xyz;
View created.
RENE> desc v1
Name Null? Type
RENE> create view v2 as select cast(substr(a,1,3) as varchar2(4)) a from xyz;
View created.
RENE> desc v2
Name Null? Type
-- Rene Nyffenegger http://www.adp-gmbh.ch/Received on Wed Nov 16 2005 - 12:20:44 CST