7

I have a postgresql 9 installation on windows, which doesn't have built in uuid generator. There is OSSD package, which can be bound to postgresql as uuid generator, but it's for *nix only (I think).

How can I generate uuid in windows postgresql?

1
  • Update: Postgres 18+ offers uuidv7 & uuidv4 functions built-in. You’ll want Version 7 UUIDs for indexing. See my Answer on related Question. Commented Oct 9 at 23:31

3 Answers 3

15

The one-click installer from EnterpriseDB does have it. The DLL is called "uuid-ossp.dll" and resides in "(Postgres' installation directory)\lib" and the installation SQL script is called "uuid-ossp.sql" and resides in "(Postgres' installation directory)\share\contrib". You have to execute the last one in the DB of your choice.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks! To add to the answer, I have to login to the db that needs to generate uuid (not postgres db) as administrator / postgres user (not normal user).
Yes, the "Additional Supplied Modules" section of the manual mentions that.
on postgresql 9.1, you simply execute CREATE EXTENSION "uuid-ossp"
3

The uuid-ossp-module in the contrib, does work on Windows XP 32 bits. The 64 bits version is not available yet, the OSSP UUID library project has to fix this problem.

Comments

2

On windows, I did the following to generate UUIDs:

Log into the server using this command on Command Prompt:

psql -U postgres

This is basically accessing PostgreSQL as root.

Then select the database you want this function to be available in:

postgres=# \c <name of database>

Then execute the following:

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

Then test by immediately executing:

SELECT uuid_generate_v4();

I recommend you review the uuid-ossp documentation on the available UUID functions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.