I am using postgresql, and suppose I have the following query.
insert into table_name values (1, 1), (1, 3);
And lets say inserting values (1,3)
fail. Do the values (1,1)
get inserted?
From the tests I have done, the first values that do not cause any errors do not get inserted, but I haven't been able to find any sources to back that up. What I have tried to google has come up with different subjects.
In general when inserting multiple values, is it an all or nothing type of thing? Or is it possible for only some of the values to get inserted?
Thanks
Do the values (1,1) get inserted?
No. Each statement in Postgresql is a transaction in itself
From the manual:
PostgreSQL actually treats every SQL statement as being executed within a transaction. If you do not issue a BEGIN command, then each individual statement has an implicit BEGIN and (if successful) COMMIT wrapped around it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With