网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > 数据库 > SQL技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
数据库:数据库教程,数据库技巧,Oracle教程,MySQL教程,Sybase教程,Access教程,DB2教程,数据库安全,数据库文摘
本月文章推荐
.如何将非归档日志模式切换到归档.
.一些有用的sql语句实例.
.将文本文件导入Sql server数据库 .
.利用UltraEdit快速将SQL语句转换.
.教你轻松掌握数据仓库的规划和构.
.用一条SQL实现:一行多个字段数据.
.微软需要改进SQL Server的六大功.
.DBA:在生产环境中创建监控表DML的.
.SQL语句应当如何使用内嵌视图与临.
.TOP N 和SET ROWCOUNT N 哪个更快.
.讲解SQL 2000的Collection排序规.
.高级复制中mlog$表的HWM过高导致.
.详细讲解各种数据库使用JDBC连接.
.一个写的很不错的获取单据编号存.
.MS SQL用ROWCOUNT解决TOP子句不支.
.深入讲解数据库性能调优技术中的.
.将XML文件导入SQL Server 2000.
.用SQL Server Everywhere保存离线.
.SQL Server 2005返回刚刚插入的数.
.将sql server中的自动增长序列,.

扩展微软 SQL Server 的空间功能

发表日期:2007-2-12


Make Microsoft SQL Server geospatial

【原文】:http://www.sharpgis.net/2006/05/14/MakeMicrosoftSQLServerGeospatial.aspx

【翻译】:小粟 日期:2007年2月11日

I’ve always thought that on the spatial support, MSSQL was way behind many of the other database servers, in its lack of supporting storage of geometry. With the new .NET CLR you can actually add your own .NET-based object types and I’ve also tried implementing the Simple Features Specification in SQL Server. There are some limitations that made me give this up though. First of all, a user data type cannot be more than 8000 bytes. That is at most no more than 500 vertices in a geometry object, which is far too little for an accurate coastline for instance. Another problem is that SQL Server doesn’t support inheritance chains, so you can’t make a good object-oriented implementation of your datatype either.

… so yesterday I went for a completely different and much simpler approach. I decided to just store the geometry as Well-Known Binary in an image column. The reason for using an image column is that it can hold up to 2Gb of data, which should be sufficient for most geometry objects . A binary field has the same 8000 byte limitation as UDT so this is no good. In addition to the geometry field, I create four real-type fields, holding the min/max values of the geometry envelope. This makes it efficient to do boundingbox based queries on the data. Any additional fields would be attributes for the geometry object.

I implemented the whole thing using SharpMap. First I created a small upload application that takes a shapefile, creates a table in the database and uploads the geometry and attributes to it. SharpMap has the necessary data readers and WKB formatters for this. The second part was to create a data provider from which SharpMap could draw from. I more or less based this on the PostGreSQL/PostGIS data provider for SharpMap, by changing the boundingbox query to use the four envelope fields. All this was not much more than an hour’s work, so it is very simple to accomplish.

I must say I was very surprised by the performance of the approach. It is just slightly faster than the shapefile data provider, which used to be the fastest data provider for SharpMap. In comparison the PostGreSQL/PostGIS is generally 4-6 times slower.

I have created a small demo web-application you can download from here. It contains two pages: one for uploading to the database, and one for rendering a layer from the database. All you need to do is to add an empty SQL Server 2005 Express database to the \App_Data\ folder and name id "GeoDatabase.mdf".

Download SharpMapSqlServer.zip (181,74 KB) (updated May 20, 2006)

Update: The MsSqlProvider is now also included in v0.9RC1, including a method for uploading from any of the SharpMap datasources to MS SQL.

扩展微软 SQL Server 的空间功能

我经常想,在对空间信息的支持上,由于它缺乏对几何体的存储, MSSQL 总是比别的数据库慢了一拍。在新的 .NET CLR 的支持下,你可以真正地添加你自己的基于 .NET 的对象。尽管我也试了下在 SQL Server 中实现简单几何类型的存储,但有一些限制使我不得不放弃了尝试。首先,用户数据类型不能超过 8000 字节。也就是说,几何体对象不能超过 500 个节点,这对像海岸线这样的对象就显得太少了。另一个问题是 SQL Server 不支持继承,所以你也不能对你的数据类型做比较好的面向对象实现。

… 所以昨天我试着找到了一个完全不同的更简单的实现。我决定以 Well-Known Binary 的形式(译者注: OpenGIS 的说明书中定义了两个表述空间对象的标准方式:一个是 WKT ( the Well-Known Text )形式,另一个是 WKB ( the Well-Known Binary )形式)存储几何体在一个图像列中。使用图像列的目的是它能够保存大到 2G 的数据,这对大多数的几何对象都足够了。而字节列和用户自定义类型一样,也有 8000 个字节的限制,所以也不够好。除了几何列之外,我还创建了四个实数类型的列,用来存储几何外接矩形框的最大最小坐标值。这能提高基于外接矩形框的查询的效率。其它的列用来存储几何体的属性。

我在 SharpMap 中实现了这个方法。首先,我建立了一个小的数据库导入程序用来导入 shapefile 文件。它在数据库中建立一个表,然后把几何体及其对象导入其中。 SharpMap 为其提供了必要的数据读取器和 WKB 格式化程序。第二个部分是建立了一个数据提供接口, SharpMap 能够基于这个接口绘制数据。我做这些时多少参照了 PostGreSQL/PostGIS 的数据提供接口,只是用四个外框坐标列来做外接矩形框查询。所有这些工作所发费的时间不超过一个小时,因此,可以说做起来是比较简单的。

我必须说,对于这种方法的效率我是很惊讶的。它比 shapefile 的数据接口还快一点点,而 shapefile 数据接口曾经是 SharpMap 中最快的数据接口。而 PostGreSQL/PostGIS 相比而言要慢 4 - 6 倍。

我在这里创建了一个可下载的 web 演示程序。它分为两页:一个是导入到数据库,另一个是从数据库读取数据和绘制图层。所有你要做的是在 \App_Data\ 文件夹中增加一个 SQL Server 2005 Express 数据库并把它命名为 "GeoDatabase.mdf" 。

下载 http://www.sharpgis.net/ct.ashx?id=d3710d85-a735-4efc-aad7-f9c8f4844c1e&url=http%3a%2f%2fwww.sharpgis.net%2fcontent%2fbinary%2fSharpMapSqlServer.zip (181,74 KB) (2006 年 5 月 20 日更新 )

更新:现在, MSSQL 数据接口也包含在 0.9RC1 版中,包含一个导入所有 SharpMap 支持的数据格式到 MS SQL 的方法。

译注:这是一篇比较长的文章,花了我大约一个半小时的时间,但是还是翻译得比较粗糙,请大家改进。

上一篇:如何清除SQL日志 人气:9271
下一篇:SQL Server实用经验与技巧大汇集 人气:4349
浏览全部SQL Server的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐