I am trying to load postgis.sql files into a pgAdmin database (using psql) that has already been created so I can create a spatially enabled database. I have confirmed that the language "plpgsql" already exists, but I cannot execute the following functions:
psql -d yourdatabase -f lwpostgis.sql;
psql -d yourdatabase -f lwpostgis_upgrade.sql;
psql -d yourdatabase -f spatial_ref_sys.sql;
I just get the generic "syntax error at or near...".
Maybe I am not formatting the line right, because from what I have read, this should work? do I really need "psql"? what does "-d" do? I tried without psql in front of the commands and bupkiss. Thoughts are appreciated...thanks.
The -d yourdatabase
option connects to this database once psql has started.
The -f file.sql
option says to load file.sql and execute all the SQL commands it contains.
If you're already inside psql
, the equivalent commands would be:
\c yourdatabase
: connect to the db named yourdatabase
.
\i file.sql
: loads file.sql
and execute all commands in it. It should be in the current path, otherwise specify a full path.