Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 '12 at 3:19
up vote 2 down vote accepted

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

share|improve this answer
As it says in the documentation, DROP TABLE works just as well in v2.0 – L_Holcombe Nov 22 '12 at 5:18
Right, PostGIS 2.0 does not have physical geometry_columns anymore, so standard drop is just fine. – JaakL Nov 22 '12 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 '12 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;"
share|improve this answer
just updated the question – Sam007 Nov 22 '12 at 1:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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