示例:确定地理数据库中已版本化的数据集

可通过查询 GDB_Items 表(或在 Oracle 中查询 GDB_Items_vw 视图)中的定义列来返回一列版本化值被设置为 true(或 1,取决于具体的数据库)的要素类。

正如快速浏览:对企业级地理数据库使用 SQL中所述,您必须创建版本化视图,才能使用 SQL 编辑版本化数据。因此,确定地理数据库中的哪些要素类已版本化是非常有用的,这样便可知道在使用 SQL 编辑要素类的版本化视图之前,是否需要先创建这些视图。

以下查询示例将返回地理数据库中已执行了语句的所有版本化要素类的列表。

注注:

应当只对这些查询所返回的部分要素类使用 SQL 进行编辑,即使在使用版本化视图时也是如此。有关详细信息,请参阅可使用 SQL 编辑何种数据类型?

请确保在执行此查询之前已连接到正确的数据库。

--Queries PostgreSQL
--Returns a list of versioned datasets in the specified geodatabase

SELECT name AS "Versioned feature class", 
FROM sde.gdb_items
WHERE (xpath('//Versioned/text()', definition))[1]::text = 'true';
--Queries a dbo-schema geodatabase in SQL Server
--Returns a list of versioned datasets in the specified geodatabase

SELECT NAME AS "Versioned feature class" 
FROM dbo.GDB_ITEMS
WHERE Definition.exist('(/*/Versioned)[1]') = 1
AND Definition.value('(/*/Versioned)[1]', 'nvarchar(4)') = 'true'
--Queries Oracle
--Returns a list of versioned datasets in the specified geodatabase

SELECT items.name AS Dataset,
	      itemtypes.name AS Dataset_Type
FROM sde.gdb_items_vw items,
	    sde.gdb_itemtypes itemtypes
WHERE	items.definition LIKE '%Versioned>true%'
	AND items.type = itemtypes.uuid;
5/25/2014