For future reference, when loading an SQL script with psql, to stop and exit on the first error, add the option: -v ON_ERROR_STOP=1 This is off by default, which is why you saw the repeated (and useless) error messages. With this option enabled, you will only see the first error, so you will know the real error. -Mike