MYSQL - DROP SPATIAL REFFERENCE SYSTEM Statement



DROP SPATIAL REFFERENCE SYSTEM Statement

You can DELETE a SPATIAL REFFERENCE SYSTEM using the DROP SPATIAL REFFERENCE SYSTEM statement.

Syntax

Following is the syntax the SPATIAL REFFERENCE SYSTEM statement −

DROP SPATIAL REFERENCE SYSTEM
   [IF EXISTS]
   srid

Example

Suppose we have created a SPATIAL REFERENCE SYSTEM in MySQL database −

CREATE SPATIAL REFERENCE SYSTEM 1004326 NAME 'WGS 84 (long-lat)' 
DEFINITION 'GEOGCS["WGS ",DATUM["World Geodetic System 1984",
SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,
AUTHORITY["EPSG","9122"]],AXIS["Lon",EAST],AXIS["Lat",NORTH]]' 
DESCRIPTION 'WGS 84 with coordinate axes swapped to be 
longitude-latitude instead of latitude-longitude';

Following query drops the above created SPATIAL REFERENCE SYSTEM −

DROP SPATIAL REFERENCE SYSTEM 1004326;

The IF EXISTS clause

If you try to drop a SPATIAL REFFERENCE SYSTEM that doesn’t exist, an error will be generated as shown below −

DROP SPATIAL REFERENCE SYSTEM 12345678;
ERROR 3548 (SR001): There's no spatial reference system with SRID 12345678.

If you use the IF EXISTS clause along with the DROP SPATIAL REFFERENCE SYSTEM statement as shown below, the specified special system will be dropped and if an SRS with the given name, doesn’t exist the query will be ignored.

DROP SPATIAL REFERENCE SYSTEM IF EXISTS 12345678;
mysql_statements_reference.htm
Advertisements