Example: Finding domain owners using SQL
You can use SQL to find the owners of all domains in a geodatabase by querying the tables GDB_ItemTypes and GDB_Items (or GDB_Items_vw view in Oracle).
The following examples show how to extract a value from a specific XML document using an XPath expression to find the owners of all domains in a specific geodatabase.
Be sure to connect to the correct database before executing this query.
--SQL Server SELECT items.Name AS "Domain Name", items.Definition.value('(/*/Owner)[1]','nvarchar(max)') AS "Owner" FROM dbo.GDB_ITEMS AS items INNER JOIN dbo.GDB_ITEMTYPES AS itemtypes ON items.Type = itemtypes.UUID WHERE itemtypes.Name IN ('Coded Value Domain', 'Range Domain')
--PostgreSQL SELECT items.name AS "Domain Name", (xpath('//Owner/text()', definition))[1]::text as "Owner" FROM sde.gdb_items AS items INNER JOIN sde.gdb_itemtypes AS itemtypes ON items.type = itemtypes.uuid WHERE itemtypes.name IN ('Coded Value Domain', 'Range Domain');
--Oracle SELECT items.name AS domain_name, EXTRACTVALUE(xmltype(items.definition), '*/Owner') Owner, itemtypes.Name AS domain_type FROM sde.gdb_items_vw items INNER JOIN sde.gdb_itemtypes itemtypes ON items.Type = itemtypes.UUID WHERE itemtypes.Name IN ('Coded Value Domain', 'Range Domain');
2/5/2013