From: | "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com> |
---|---|
To: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: data type change on a view |
Date: | 2007-12-12 18:28:38 |
Message-ID: | dcc563d10712121028n7564bdcdn1d2361fc91317f2b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Dec 12, 2007 12:11 PM, A. Kretschmer
<andreas(dot)kretschmer(at)schollglas(dot)com> 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...
From | Date | Subject | |
---|---|---|---|
Next Message | Ivan Sergio Borgonovo | 2007-12-12 18:33:11 | Re: General Q's |
Previous Message | Joshua D. Drake | 2007-12-12 18:25:43 | Re: Slow PITR restore |