What is a query layer?
A query layer is a layer or stand-alone table that is defined by a SQL query. Query layers allow both spatial and nonspatial information stored in a DBMS to be easily integrated into GIS projects within ArcMap. Since query layers are using SQL to directly query database tables and views, spatial information used by a query layer is not required to be in a geodatabase.
When working in ArcMap, you create query layers by defining a SQL query. The query is then run against the tables and views in a database, and the result set is added to ArcMap as a layer or stand-alone table (depending on the query).
The query is executed every time the layer is displayed or used in ArcMap. This allows the latest information to be visible without making a copy or snapshot of the data and is especially useful when working with dynamic information that is frequently changing. The query layers functionality works with any of the DBMSs supported by ArcGIS.
Query layers allow ArcMap to integrate data from geodatabases as well as from DBMSs. Therefore, query layers can quickly integrate spatial and nonspatial information into GIS projects independently of where and how that information is stored.
A quick tour of working with Query Layers
- Users in ArcMap can add Query Layers to the map by defining a query against the tables and views in a DBMS.
- Query Layers behave like any other feature layer or stand-alone table, so they can be used to display data, used as input into a geoprocessing tool, or accessed programmatically using developer APIs.
- After a Query Layer has been created, it can be saved as a layer file (.lyr) or used to create a layer package (.lpk). This makes it easy to share Query Layers with other applications, map documents, and other users.