Now that the SQL is fixed you can run it via:
psql -U username < /path/to/sqlfile
Output would now look like this:
DROP DATABASE
CREATE DATABASE
You are now connected to database "animalsdb" as user "postgres".
CREATE TYPE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
INSERT 0 1
id | name
----+------
1 | Jim
(1 row)
BEGIN
INSERT 0 1
INSERT 0 1
COMMIT
BEGIN
INSERT 0 1
ERROR: insert or update on table "dog" violates foreign key constraint "dog_id_fkey"
DETAIL: Key (id, type)=(1, dog) is not present in table "animal".
ROLLBACK
id | type | name
----+------+-------
1 | cat | macho
(1 row)
ERROR: insert or update on table "dog" violates foreign key constraint "dog_id_fkey"
DETAIL: Key (id, type)=(1, dog) is not present in table "animal".
id | type | name
----+------+------
(0 rows)
ERROR: new row for relation "dog" violates check constraint "dog_type_check"
DETAIL: Failing row contains (1, cat, 1).