Database view
You can define views on a single feature class or table (for instance, to limit a user's access to the columns in a feature class), between two feature classes, or between a feature class and a table, or you can create more complex views containing subqueries.
创建视图的语法:
sdetable -o create_view -T <view_name> -t <table1,table2...tablen>
-c <table_col1,table_col2...table_coln>
[-a <view_col1,view_col2...view_coln>] [-w <"where_clause">]
[-i <service>] [-s <server_name>] [-D <database>]
-u <DB_user_name> [-p <DB_user_password>] [-N] [-q]
其中:
-T 为视图名,创建完成后,在arccatalog中浏览与普通的table或是featureclass相同;
-t 为参与的表名,各表间用“,”隔开,另外,各表名前需加上所属用户,如:sde.tablename;
-c 为目标视图列,一般格为:用户.表名.字段名,如:sde.sampletable.samplefield。可用.*代表所指定表的所有字段。若参与的table有featureclass(空间表),则若指了shape字段,则结果视图将带有空间信息,与featureclass相似,若没有指定shape字段,则为普通表,与table类似。
[-a ]为可选项,一般不用设置;
[-w <"where_clause">]为视图的逻辑条件,为一般的SQL语句where 后面的语句,注意:该语句需用双引号;
[-i ] [-s ] [-D ]为指定ArcSDE所在服务器,数据库名以及服务名,若是在本机上操作,则这些参数可省;
[-u ]为用户名,该用户名为SDE用户名;
[-p ]为SDE密码,即登陆SDE数据库的密码。
以下为创建一个带有空间信息的视图例子:
sdetable -o create_view -T RllkView -t grgwsde.rllk, grgwsde.fm -c grgwsde.rllk.Shape, grgwsde.fm.* -w "grgwsde.rllk.FieldID = grgwsde.fm.FieldID" -u sde -p sde
注意:
1、在进行数据编辑时需要注意,如果是对空间数据进行非版本编辑的话(直接操作的是图层对应的基表信息),打开视图可以实时看到更新的数据
2、如果是对空间数据进行版本编辑的话,利用视图查询并不能看到最新的数据,如果对数据进行协调提交压缩等操作到基表即可。创建此种类型的视图是针对图层基表进行创建的。
利用Using Multiversioned Views进行查询
sdetable -o create_mv_view -T <view_name> -t <table>
[-i <service>] [-s <server_name>] [-D <database>]
-u <DB_user_name> [-p <DB_user_password>] [-N] [-q]
官方英文解释
To access the attribute information of a multiversioned feature class from a client application that does not recognize versioning, you can create a multiversioned view. Multiversioned views should only be used with simple geodatabase objects (those not involved in networks or topologies), can only be applied to one versioned table or feature class, and cannot include the spatial column of the table. You cannot create a multiversioned view on a view. The following example creates a multiversioned view, world_imv_view, on the base table of the feature class world.
c:\> sdetable -o create_mv_view -T world_imv_view -t world -u av -p morti26
Unlike a standard ArcSDE view, you do not choose columns or define a WHERE clause. The schema of a multiversioned view is identical to that of the business table on which it is based.
When querying a multiversioned view, you need to specify which version. Using the DBMS SQL interface, set the current version by executing the stored procedure sde.version_util.set_current_version. (This stored procedure is not supported on all DBMSs.)
For example, if the current version of the database you want to access is called working, set the database to that version during the SQL session.
Multiversional Views是将图层的BaseTable以及相应图层的增量表中相应版本的数据组织成的View。从指定版本的视图中可以获得版本数据的变化情况及所有属性信息。Multiversional Views只适用于GDB数据模型中简单数据对象,其中包括版本话的FeatureClass、Table等,并不包含GeometryNetwork及拓扑。在所建的视图中并不能包含空间数据列,只包含其属性列。
同时在所建的视图中并不能像DatabaseView包含一些复杂的条件语句,在使用的时候要调用Arcsde存储过程sde.version_util来设置当前访问的版本名称。
要注意的地方是:
(1)在一个Feature Class中只能有一个Multiversional View;
(2)能够对Multiversional View执行所有的版本化操作,包括:creating versions, resolving conflicts, reconciling, and posting;
(3)Multiversional View不能用来获取或者修改复杂要素,例如Geometric Networks,Topology,Relationship;
(4)不能利用Multiversional View编辑Default版本,或者属于其它编辑和协调操作的版本;
(5)不能够利用DBMS工具更新任何ID字段(OBJECTID)
(6)只适用于图层相关的属性查询,对与空间位置相关的查询无能为力。