Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a temporary database with postgresql initdb?

How do I create a temporary database for PostgreSQL using initdb? Also, how do I populate it with dummy data and how do I delete it after usage?

I have an entire schema of the database. I don't want to create temporary tables one by one. Using initdb, I would like to be able to give the schema and get a database with the tables, etcetera created.

This is for running integration tests of a spring boot application. I use mybatis to access the database.

Can I use any other tool like arquillian?

like image 693
Tarun Maganti Avatar asked Jul 10 '26 11:07

Tarun Maganti


1 Answers

There's a workaround this, just change the data directory to a RAM file system, like this once you restart your computer, the data is gone. better you won't change anything in your scripts.

like image 200
rachid el kedmiri Avatar answered Jul 13 '26 17:07

rachid el kedmiri



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!