Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
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 '12 at 3:19
add comment

2 Answers 2

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
add comment
  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
add comment

Your Answer

 
discard

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.