I'm using PostgreSQL 9.2.4.

I'm working with multiple tables with large number of data.

I have two tables Table_One which has one of the field with varchar(250) and Table_Two with one of the field varchar(200).

Lets say, Table_One has 20 records in which 2 records has field with 250 characters.

I'm doing a bulk insert by some query like below

insert into Table_Two(id, INSTANCEwithVarchar, MIN, MAX)(SELECT id, INSTANCEwithVarchar, MIN, MAX from Table_One)

I will get an exception while inserting the record of Table_One which has varchar 250.

My question is,

Will Table_Two has 18 records inserted?

Or bulk insert into Table_Two will fail completely even if one record among the 20 gets violate the constraints?

If not, say if Table_Two has 18 records added, then in what order the failure will happen? if the first record of Table_One has varchar 250, then will the whole process fail or pgsql itself ignores failures and add remaining records successfully?

(Using PostgreSQL 9.2)

1 Answer 1


Your statement runs in a transaction. If there is not already a transaction open, a transaction is created just for this statement and automatically committed at the end if the statement succeeds.

If the statement encounters an error, the transaction is rolled back automatically, so it has no effect.

Either the whole statement takes effect or none of it does.

(Note that you could've just tried it to determine this).

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.