Selecting only Spatial tables from PostgreSQL database?

All spatial table references are held in the geometry_columns metadata table. So try:

select * from geometry_columns

and you should get just the spatial tables


Another one to select only spatial tables in database..

SELECT table_name FROM information_schema.columns WHERE column_name = 'the_geom'`

Using this code we can also retrieve table info by knowing its column name.


Short way

select * from geometry_columns

Deeper way

SELECT table_name FROM information_schema.columns WHERE column_name = 'the_geom' or column_name = 'wkb_geometry'

The second option should work even if the information of geometry_columns have been deleted. The 'wkb_geometry' is the default name of geometry data columns if you used ogr2ogr tool to feed your database.