BowerStudios.com

  • My Lab
  • Family
  • Friends
  • Professional
  • About
Home

Postgresql UUIDs

daniel —Tue, 08/02/2011 - 2:54pm

  • SQL

The UUID type.

You don't need to do anything additional to insert/update/read uuids in postgres, but if you want to generate them, you'll need to enable the functions with a script from contrib first:
psql -d -U -f /usr/share/postgresql-8.4/contrib/uuid-ossp.sql

Then you can:
select uuid_generate_v4();

You should see a uuid in the output.

The functions available via the uuid-ossp module

Other examples of UUID use:
Alter a table to automatically generate uuids:
alter table my_table alter column id set default uuid_generate_v4();

Create a table to automatically generate uuids:
CREATE TABLE my_table ( id UUID DEFAULT uuid_generate_v4() PRIMARY KEY);

Postgres 9.1

  • Log in to post comments

Navigation

  • Search
  • Recent content
  • Contact Me
  • Mail
  • Pass Hasher
  • Bower Studios Admin

Quotes

daniel —Wed, 12/26/2007 - 1:49pm

Talent hits a target no one else can hit; Genius hits a target no one else can see.

—

Arthur Schopenhauer

  • Log in to post comments
  • daniel's quotes

Popular content

Last viewed:

  • Monitoring Java/Groovy Apps
  • Thomas A. Edison
  • Using git remotely with ssh keys
  • Blogs that amused/informed me today
  • Install Ruby/Rails on Ubuntu 10.04

Copyright 2019 Daniel Bower
  • My Lab
  • Family
  • Friends
  • Professional
  • About