Re: Converting between UUID and VARCHAR - Mailing list pgsql-sql

From A. Kretschmer
Subject Re: Converting between UUID and VARCHAR
Date
Msg-id 20081110144442.GE14544@a-kretschmer.de
Whole thread Raw
In response to Converting between UUID and VARCHAR  (Mario Splivalo <mario.splivalo@megafon.hr>)
Responses Re: Converting between UUID and VARCHAR
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Mario Splivalo
Date:
Subject: Converting between UUID and VARCHAR
Next
From: "Johnson, Michael L."
Date:
Subject: Subsorting GROUP BY data