Why use the SQL Server 2008 geography data type?

前端 未结 3 903
旧巷少年郎
旧巷少年郎 2021-01-29 18:04

I am redesigning a customer database and one of the new pieces of information I would like to store along with the standard address fields (Street, City, etc.) is the geographic

3条回答
  •  遥遥无期
    2021-01-29 18:43

    Another thing to consider is the storage space taken up by each method. The geography type is stored as a VARBINARY(MAX). Try running this script:

    CREATE TABLE dbo.Geo
    (
        geo geography
    
    )
    
    GO
    
    CREATE TABLE dbo.LatLon
    (
        lat decimal(9, 6)
    ,   lon decimal(9, 6)
    
    )
    
    GO
    
    INSERT dbo.Geo
    SELECT geography::Point(36.204824, 138.252924, 4326) UNION ALL
    SELECT geography::Point(51.5220066, -0.0717512, 4326) 
    
    GO 10000
    
    INSERT dbo.LatLon
    SELECT  36.204824, 138.252924 UNION
    SELECT 51.5220066, -0.0717512
    
    GO 10000
    
    EXEC sp_spaceused 'dbo.Geo'
    EXEC sp_spaceused 'dbo.LatLon'
    

    Result:

    name    rows    data     
    Geo     20000   728 KB   
    LatLon  20000   400 KB
    

    The geography data-type takes up almost twice as much space.

提交回复
热议问题