Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm wanting to parse through an entire ArcSDE database (feature dataset, features classes, tables, everything...) searching for a field (compkey) and export the numbers to a txt file.

share|improve this question

closed as unclear what you're asking by PolyGeo, Chad Cooper, Mapperz May 21 '14 at 13:52

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

So what's your question exactly? And what DBMS is being used? – blah238 Mar 5 '12 at 11:47

If your data is not versioned (or you've compressed and updated the base tables), you could just use SQL to query out the IDs.

For a manual, one-time-only, type of query, I've used this SQL query (ORACLE) to generate a second SQL query. You could replace the COUNT(*) as ROWCOUNT with a COMPKEY and add additional where clause conditions (you will probably want to change OWNER ='SDE' to OWNER IN ('SCHEMA1','SCHEMA2','SCHEMA3') if you have GIS data in multiple schemas).

    'SELECT COUNT(*) as ROWCOUNT,'''|| t.owner||'.'||t.TABLE_NAME||''' as ClassName FROM '||t.OWNER||'.'||t.TABLE_NAME||' UNION' as SelectStatement 
from sde.table_registry t
where t.owner = 'SDE'
and t.owner||'.'||t.TABLE_NAME in (select OWNER||'.'||TABLE_NAME  
from all_tab_cols where column_name = 'COMPKEY' and OWNER ='SDE'
order by t.table_name

So the above query will generate a list of select statements with a 'UNION' at the end.

copy/paste that into a new query window (delete the 'UNION' from the last line). and that will give you your list. If you are using SQL Developer or Toad, those applications have built-in capability to export to text file.

If your data is versioned, you should probably look at building multi-versioned views for the versioned featureclasses. Assuming that you would be querying from each featureclass/table at the same version, you could do the same sort of union query but using the multi-version views.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.