I added a shapefile to the PostGIS using,

ogr2ogr -f PostgreSQL PG:"host=server_ip user=username dbname=dbname password=password" yourshapefile.shp;

Now I want to remove it. What is the command line code for that?

The table list is as follows \d,

List of relations
 Schema |         Name         |   Type   |  Owner  
 public | pimapine             | table    | smaranh
 public | pimapine_ogc_fid_seq | sequence | smaranh
(2 rows)

And when I execute DROP TABLE public.pimapine there is no change to the output of \d.

  • 2
    Did you include a semicolon at the end of your DROP TABLE command? Psql won't throw an error if you don't terminate your SQL statements with a semicolon. When the command has been accepted, it will print "DROP TABLE" on a line by itself.
    – L_Holcombe
    Nov 22, 2012 at 3:19

2 Answers 2


The cleanest way is with the DropGeometryTable function. This will remove the table as well as entries in the geometry_columns table.

  • As it says in the documentation, DROP TABLE works just as well in v2.0
    – L_Holcombe
    Nov 22, 2012 at 5:18
  • Right, PostGIS 2.0 does not have physical geometry_columns anymore, so standard drop is just fine.
    – JaakL
    Nov 22, 2012 at 7:04
  • Since he didn't specify version and DropGeometryTable is still in 2.0, I figured this was the cleaned way.
    – Sean
    Dec 6, 2012 at 16:19
  1. open your db with pgadmin
  2. find the shapefile-table in the public schema
  3. drop it

or if you want to use psaq:

psql -c "drop table public.shapefile;"
  • just updated the question
    – Sam007
    Nov 22, 2012 at 1:21

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.