Geodatabase模型结构解析之多版本视图

geodatabase视图和版本化:https://max.book118.com/html/2019/0329/8010047125002014.shtm


This topic contains the following information:本主题包含以下内容:

What are multiversioned views?什么是多版本视图?

Multiversioned views incorporate database views, stored procedures, triggers, and functions to access a specified version of data in a geodatabase table using structured query language (SQL).

多版本视图包含数据库视图、存储过程、触发器和函数,以使用结构化查询语言(SQL)访问地理数据库表中指定版本的数据。
Multiversioned views access a specified version of data in the business table of a dataset. The dataset must be registered as versioned. Each versioned dataset has associated delta tables that record edits made to the dataset. When a versioned dataset is accessed by a multiversioned view, all the records in the business table are selected and merged with records from the delta tables to construct a view that includes all the changes made to the business table in the context of the specified version. Multiversioned views appear to have the same columns and rows as the business table they represent. Unlike database or spatial views, multiversioned views are used not to change the table's schema or limit access to it; rather, they are used to facilitate access to a certain version of the table.

多版本视图访问数据集的业务表中指定版本的数据。数据集必须注册为版本。每个版本化的数据集都有相关的增量表,记录对数据集所做的编辑。当多版本视图访问版本数据集时,将选择业务表中的所有记录,并将其与增量表中的记录合并,以构造一个视图,该视图包含在指定版本的上下文中对业务表所做的所有更改。多版本视图似乎与它们所表示的业务表具有相同的列和行。与数据库或空间视图不同,多版本视图不用于更改表的模式或限制对表的访问;相反,它们用于方便访问特定版本的表。
不支持ArcSDE地理数据库版本控制的应用程序只能直接查询版本化数据集的业务表,而不知道增量表。在这些应用程序中使用多版本视图,使它们能够访问增量表中的数据。


Applications that do not support ArcSDE geodatabase versioning can only directly query the business table of a versioned dataset and have no knowledge of the delta tables. Using multiversioned views with these applications provides them with access to the data in the delta tables.

多版本视图主要用于访问表的属性列,而不是空间列,尽管可以访问空间列。如果使用空间类型(如STu Geometry或SDOu Geometry)来存储几何图形,则使用多版本视图访问空间列更为直接;如果您使用的是二进制几何体存储类型,例如ArcSDE压缩二进制或OpenGeospatialConsortium,Inc.(OGC)众所周知的二进制类型,则涉及的内容更多。



Multiversioned views are designed primarily to access attribute columns of a table rather than spatial columns, though it is possible to access the spatial column. Accessing the spatial column with a multiversioned view is more straightforward if you are using a spatial type, such as ST_Geometry or SDO_Geometry, to store your geometries; it is more involved if you are using a binary geometry storage type, such as the ArcSDE compressed binary or the Open Geospatial Consortium, Inc. (OGC) well-known binary types.

It is possible to edit a versioned table using multiversioned views. This is an advanced use of views, is database management system (DBMS) specific, and has the potential to corrupt your geodatabase if not done properly.

The general steps you take to edit with multiversioned views are as follows:

  1. Create a version in which to do your edits.
  2. Set the multiversioned view to use the new version.
  3. Start an edit session.
  4. Perform your edits through the multiversioned view.
  5. Stop the edit session.
  6. Commit your edits to the database or roll them back.
  7. If you reconcile and post your edits through ArcGIS, you can delete the version you created for your edits.

For instructions on how to set up this type of editing, see the "Editing with multiversioned views" sections for each DBMS.

Creating and deleting multiversioned views


Use the administration command sdetable –o create_mv_view to create a multiversioned view on a single business table that has already been registered as versioned through ArcGIS.

This example creates a multiversioned view of the parcels feature class.

sdetable –o create_mv_view –T mv_parcels –t parcels -i 5100 –D landbase –u bjorn –p a.secret



Notice that you do not choose columns or define a WHERE clause when using the sdetable –o create_mv_view command as you do when you create standard or spatial views using sdetable –o create_view or SQL.

Also, be aware that only one multiversioned view can exist per feature class, and you cannot create a multiversioned view on a view.

To remove a multiversioned view, use the command sdetable –o delete_mv_view. For example, to delete the multiversioned view created in the last example, type the following:

sdetable –o delete_mv_view –t parcels -i 5100 –D landbase –u bjorn –p a.secret



For complete syntax, explanation, and examples of the sdetable –o create_mv_view and sdetable –o delete_mv_view commands, see the Administration Command Reference provided with the ArcSDE component of ArcGIS Server Enterprise.


Using multiversioned views in DB2

Multiversioned views can be used to read the data in a versioned dataset and also to edit the dataset.

Reading data with multiversioned views
Multiversioned views automatically access the DEFAULT version. Before issuing any queries against the view, you must ensure that they will take place against the correct version. To access a specific version other than the default, execute the ArcSDE setcurrentversion stored procedure. This procedure validates the supplied version name and sets the corresponding database state internally. It can be executed directly from a SQL client. The syntax for the stored procedure to set the current version is as follows:

CALL sde.setcurrentversion('<version_name>',?,?)



For example:

CALL sde.setcurrentversion('edits',?,?)



This procedure may be called again to change to other versions as required, and it is called each time the workspace is refreshed to return the current state of the versioned table to the calling application.

NOTE: Multiversioned views should not be used to access or modify complex features—features that participate in geometric networks, topologies, or relationships or have specific geodatabase behavior. You should use ArcGIS to view and modify these types of features.



Editing with multiversioned views
When you edit versioned tables through multiversioned views, changes are made to the delta tables, and row ID values for new records are automatically generated. However, unlike editing versioned data in an ArcGIS edit session, no internal version reconciliation is done with these edits. Therefore, it is strongly recommended that multiversioned views not be used to edit the DEFAULT version or any version that may be subject to simultaneous editing or reconciliation by other users because conflicts will not be detected. Instead, create your own version specifically for editing with multiversioned views.

NOTE: If you need to perform version management operations, such as reconcilingresolving conflicts, and posting, you need to use the ArcGIS software. Improper version management can lead to geodatabase corruption when working with views. Also note that you should never use DBMS tools to update any row ID (ObjectID) field maintained by ArcSDE in the database. These row ID fields are allocated and managed by the geodatabase and should not be altered.



There are several stored procedures installed with the ArcSDE component that help you work with multiversioned views. The stored procedure used to set which version the multiversioned view will work with was discussed in the previous section. There are also stored procedures to create a version in which you can do your editing, start and stop an edit session, and delete your edit version.

The following set of steps takes you through creating a multiversioned view, creating a version in which to perform edits, setting the version to edit, starting an edit session, performing some edits through the multiversioned view, stopping the edit session, committing your edits to the database, and deleting the version created for the edits. In the examples, the multiversioned view created to perform the edits on the table is permits_mv and the version created and used for editing is mvedits.

Remember that the dataset you edit through a multiversioned view must already have been registered as versioned through ArcGIS. For this example, the permits feature class would need to have already been registered as versioned in ArcCatalog to be able to edit it through a multiversioned view.

    1. At a command prompt, execute the sdetable function to create a multiversioned view.
sdetable –o create_mv_view –T permits_mv –t permits –i 4400 –D code –u sarja –p not4u



    1. Create a new version in which to perform your edits.
CALL sde.create_version
('<parent_version>', '<child_version>', <name_rule>, <access>, '<description>',
<message_code_output>, <message_output>)



      where



      <parent_version> is the version from which your version is created.
      <child_version> is the name for the version you are creating.
      <name_rule> indicates whether the name specified for the version should be taken as given (2) or a unique name should be created when a duplicate name is specified (1).
      <access> is the permission level for the version; either 0 for Private, 1 for Public, or 2 for Protected.
      <description> is a text description of the child version.
      <message_code_output> indicates you want the SQL code returned to you.
      <message_output> indicates you want the SQL messages returned to you.



      For example:
CALL sde.create_version
('sde.DEFAULT', 'mvedits', 1, 1, 'multiversioned view edit version', ?, ?)



NOTE: The message_code_output and message_output are the SQL codes and messages returned after you execute the function. You pass in question marks, and the code and message are returned to you.



    1. Set the version for the edit session to the child version you just created.
CALL sde.setcurrentversion('<version_name>', <message_code_output>, <message_output>)



      For example:
CALL sde.setcurrentversion('mvedits', ?, ?)



    1. Start an edit session by calling the edit_version stored procedure and specifying "1". The 1 indicates an edit session should be started.
CALL sde.edit_version('<version_name>', 1, <message_code_output>, <message_output>)



      For example:
CALL sde.edit_version('mvedits', 1, ?, ?)



    1. Perform the necessary edits to the multiversioned view using SQL.
      In this example, an existing record is updated and a new record is inserted.



UPDATE permits_mv
SET permittee_name = 'Cpt. Industry' 
WHERE business_name = 'Body Electric'



INSERT INTO permits_mv
(bid, business_name, business_type, permittee_name) 
VALUES (117, 
'Bionix', 
'engineering', 
'Anjo Badsu')



    1. Stop the edit session by calling the edit_version stored procedure, but this time, specify "2". The 2 indicates the edit session should be closed.
CALL sde.edit_version('<version_name>', 2, <message_code_output>, <message_output>)



      For example:
CALL sde.edit_version('mvedits', 2, ?, ?)



    1. Execute a COMMIT or ROLLBACK statement.
      In this example, the edits are committed to the database.
COMMIT

After the changes have been reconciled and posted through ArcGIS Desktop, or if you decide you don't want the changes, you can delete the version you created in step 1 by calling the delete_version stored procedure.

CALL sde.delete_version('<version_name>', <message_code_output>, <message_output>)



To delete the version created in step 1, execute the following statement:

CALL sde.delete_version('mvedits', ?,?)





Using multiversioned views in Informix

Multiversioned views can be used to read the data in a versioned dataset and also to edit the dataset.



http://webhelp.esri.com/arcgisdesktop/9.2/index.cfm?TopicName=Using_multiversioned_views
 
原文地址:https://www.cnblogs.com/2008nmj/p/14991344.html