I want to import a shapefile using shp2pgsql. I am using Mac with Postgis 2.2.

Based on this reference: A conversion and upload can be done all in one step using a UNIX pipe:

  shp2pgsql -s <SRID> -c -D -I <put to shapefile> <schema.<table> | \
  psql -d <databasename> -h <hostname> -U <username>

An example provided in the postgis manual is:

# shp2pgsql shaperoads myschema.roadstable | psql -d roadsdb

Not sure how to find "schema.table". I am working on a shapefile folder which has:

l_2015_us_county yan$ ls
tl_2015_us_county.cpg           tl_2015_us_county.prj           tl_2015_us_county.shp.ea.iso.xml    tl_2015_us_county.shp.xml
tl_2015_us_county.dbf           tl_2015_us_county.shp           tl_2015_us_county.shp.iso.xml       tl_2015_us_county.shx

What is the schema and table in this shapefile?


Schema is something different. Schema is in database, not somewhere with your shapefile. When you created new database, and also extensions by:


You've created new schemas in your database: public and topology. Look at the picture below:

enter image description here

In each of my databases, there are schemas. You can create new schemas, just check the documentation.



A schema is a named collection of tables. A schema can also contain views, indexes, sequences, data types, operators, and functions. Schemas are analogous to directories at the operating system level, except that schemas cannot be nested. PostgreSQL statement CREATE SCHEMA creates a schema.

The schema and table are part of the destination, not the input shapefile. The default schema is public, so try something like public.awesometable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.