Search Postgresql Archives

Re: data type change on a view

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Dec 12, 2007 12:11 PM, A. Kretschmer
<andreas.kretschmer@xxxxxxxxxxxxxx> wrote:
> Hello @all,
>
> i have a question (rot really for myself, a member of ther german forum
> asks):
>
> i have two tables, contains a varchar(N)-column. Now i create a VIEW
> based on this tables. The resulting view contains now a varchar without
> length. How can i prevent this? How can i force that the column in the
> view contains the *exact* typ?

cast it to varchar(8):

test=# create table h1 (t varchar(8));
CREATE TABLE
test=*# create table h2 (t varchar(8));
CREATE TABLE
test=*# create view h as select t::varchar(8) from h1 union all select
t from h2;
CREATE VIEW
test=*# \d h
             View "public.h"
  Column |       Type        | Modifiers
 --------+-------------------+-----------
  t      | character varying(8) |

Note that I don't have to do that in 8.2.5, it's automagic...

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux