Re: Converting between UUID and VARCHAR

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Converting between UUID and VARCHAR
Date: 2008-11-10 14:44:42
Message-ID: 20081110144442.GE14544@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Johnson, Michael L. 2008-11-10 14:56:30 Subsorting GROUP BY data
Previous Message Mario Splivalo 2008-11-10 14:34:10 Converting between UUID and VARCHAR