Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable extensions in PostgreSQL?

Tags:

sql

postgresql

I have the following SQL snippet:

CREATE TABLE chat (
    message_uuid    UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
);

which fails with the following error message:

ERROR:  function uuid_generate_v4() does not exist

As far as I can see, I need an extension to make use of this function. Does anyone know how I can activate it? The function seems to exist according to the documentation

like image 361
Daniel Stephens Avatar asked Apr 01 '26 03:04

Daniel Stephens


1 Answers

You have to enable the uuid-ossp extension. Execute this statement:

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
like image 116
HelloWorld Avatar answered Apr 02 '26 17:04

HelloWorld



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!