1

I use postgres with jdbc and I would like to delete all data from database without dropping any tables!! I would like to insert data in database using this

 <jdbc:initialize-database data-source="DataSource"> 
 <jdbc:script location="classpath:META-INF/test.sql"/> 
 </jdbc:initialize-database> 

the problem is that I got a key duplicated exception, so I have to delete all data before running this code any idea?

1
  • You can dump the DB (with pg_dump) and restore it without table content. Only table structure. Commented Jun 24, 2014 at 11:17

1 Answer 1

1

Add a TRUNCATE your_table; for all your tables at the beginning of your test.sql file.

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

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.