如何在ArcSDE中创建视图(转+自己分析)
对于在Oracle或是SQL Server等数据库中,用视图(View)来提高的表间的查询检索效率的方法会经常用到。在GIS系统中,我们也会经常需要进行表间的查询,如:从空间位置查找该空间地物相关的属性信息表。我们常规的做法一般是先通过空间查询,再用关键字段进行关联查询。但在有些情况,如:进行插值时,需要空间表的空间位置,但需要另外一张表的某个属性作为插值字段,就无法实现,必须通过视图的方式来实现。
[-u ] [-p ] [-N] [-q]
Creating a geographic view in SDE
There are two ways to create a view :
- Through ArcSDE command line commands.
- A toolbox tool in ArcCatalog. In order to use it, open the toolbox in ArcCatalog -> Data Management -> Layers and Table views -> Make Table View, and follow the wizard (for more information, check out the ArcGIS 9.2 Desktop Help).
In order to create the view, you need to use the command sdetable :
For example :
We have a layer named street_lights_g which has a foreign key to a table called streets. We need a view to contain the name of the street for each street light (so it can be displayed when you perform identification. In order to create the view we will run this command :
After running the command the view will be seen in the desktop tools like a regular layer. You can add it like a regular layer to a mxd, perform queries etc...
I recommend, to check out the spatial index of the view, to see if it exists (right click on the view in ArcCatalog -> properties -> indexes). If all the grid values are 0 then you need to recalculate the index - using the recalculate button, or enter the grid values manually with the Edit button.
Troubleshooting :
Problem :
When running the command the following error message is received :
Cause :
The schema in which you tried to create the view, already contains a view with the same name.
Solution :
Delete the view from the schema using ArcCatalog. Why ? When a geographic view is created it will be registered in the sde.layers table. If the existing view is a geographic view, and you delete it from the database via console, the table will still stay registered, and you will not be able to recreate the view.
Problem :
When running the command the following error message is received :
Cause :
Geographic view was deleted from db console, and is still registered in the sde.layers table.
Solution :
- Create a view with the same name via DB console (pl/SQL developer, SQL server management console).
- Delete the view with ArcCatalog.
- Rerun the command.