I installed uuid-ossp for the default PostgreSQL database (postgres) using the following sql commands but whenever I create a new database I am forced to run the same commands once again for every new database.

ALTER EXTENSION "uuid-ossp" SET SCHEMA public;

Is there any way to install uuid-ossp once and ensure that every new database will have uuid-ossp enabled by default?

PS. I use PostgreSQL ver. 13.1


1 Answer 1


The CREATE DATABASE command always clones some existing template database.

If this parameter is not specified, postgresql uses the template1 database as the default. Thus, any prior changes in template1 database will be part of the new database (unless another TEMPLATE has been specified explicitly).

You need connect to template1 database and create the uuid-ossp extension in this database.

  • Thanks a lot. I modified template1 Everything works smoothly as I want.
    – mbnoimi
    Jan 18, 2021 at 16:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.