Skip site navigation (1) Skip section navigation (2)

Re: Converting between UUID and VARCHAR

From: "Helio Campos Mello de Andrade" <helio(dot)campos(at)gmail(dot)com>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Converting between UUID and VARCHAR
Date: 2008-11-28 22:27:50
Message-ID: 29e3942f0811281427w45e42c15h6f05f9fd1a5b92fd@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
Didn't you create those other tables with "character varying" too? If
you did i think that you need to change those tables too.

On Mon, Nov 10, 2008 at 12:44 PM, A. Kretschmer
<andreas(dot)kretschmer(at)schollglas(dot)com> wrote:
> am  Mon, dem 10.11.2008, um 15:34:10 +0100 mailte Mario Splivalo folgendes:
>> I have a table, like this:
>>
>> CREATE TABLE t1
>> (
>>   u1 character varying
>> )
>>
>> And some data inside:
>>
>> INSERT INTO t1 (u1) VALUES ('62d6b434-7dfd-4b3b-b1bf-87f6c20c10dd');
>> INSERT INTO t1 (u1) VALUES ('e3fee596-164b-4995-9e0d-7b2a79e83752');
>>
>> Now, I can do this:
>>
>> SELECT u1::uuid FROM t1;
>>
>> But I can't do this:
>>
>> ALTER TABLE t1 ALTER u1 TYPE uuid;
>
> test=# CREATE TABLE t1
> test-# (
> test(#   u1 character varying
> test(# )
> test-# ;
> CREATE TABLE
> test=# INSERT INTO t1 (u1) VALUES
> ('62d6b434-7dfd-4b3b-b1bf-87f6c20c10dd');
> INSERT 0 1
> test=# alter table t1 alter column u1 type uuid using u1::uuid;
> ALTER TABLE
> test=# \d t1;
>     Table "public.t1"
>  Column | Type | Modifiers
> --------+------+-----------
>  u1     | uuid |
>
>
>
> Andreas
> --
> Andreas Kretschmer
> Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
> GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>



-- 
Helio Campos Mello de Andrade

In response to

pgsql-sql by date

Next:From: Milan OparnicaDate: 2008-11-30 23:13:44
Subject: Re: JOIN results of refcursor functions
Previous:From: Lennin CaroDate: 2008-11-28 15:22:54
Subject: Re: wired behaviour

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group