Modify a query layer

After you add a query layer to a map, you may decide that you want to change the SQL query or the query layer properties. To do this, open the Edit Query Layer dialog box from the Source tab of the query layer's Layer Properties dialog box.

When you add a spatial table stored in a database to the map, it creates a query layer with default properties as determined by the first row in the table. These properties may not be what you need for a specific workflow, however. For example, you can model a spatial table containing a collection of cities in the database as both a point and a polygon geometry type. But feature layers in ArcGIS can have only a single geometry type, so the first row in the table provides the default geometry type property. In this example, if the first row in the spatial table containing cities data returns a point geometry, the cities query layer will only display point features. If you prefer to view the polygon features that are stored in the cities table, modify the query layer properties on the Edit Query Layer dialog box and change the geometry type to polygon.

Other properties, such as a query layer's dimensionality, spatial reference, SRID, and unique identifier field, are also determined by the first row returned from the spatial table. Similar to the geometry type, you can access these properties by clicking Next on the Edit Query Layer dialog box and modify them.

When you change the dimensionality of the query layer, the geometry field values of the displayed features are modified to match that change.

For example, for a layer defined with x-, y-, z-, and m-dimensionality in the database, if you edit the query layer and uncheck the Coordinates include M values. Used to store route data. and Coordinates include Z values. Used to store 3D data. options under Spatial Properties, all the features in the layer will display only the x- and y-values. Alternatively, if you edit the query layer and check the Coordinates include M values. Used to store route data. and Coordinates include Z values. Used to store 3D data. options, all the features will display x-, y-, z-, and m-values. If you check those options and a feature does not contain a z- or m-value in the database, those values will appear as null in the query layer.

When you change the spatial reference or SRID of the query layer in the Spatial Properties of the Edit Query Layer dialog box, the features displayed in ArcGIS Pro are filtered based on that spatial reference or SRID value.

Note:

The properties you can alter vary depending on the query layer source.

Follow these steps to alter the definition and properties of a query layer:

  1. Open the map in ArcGIS Pro that contains the query layer.
  2. Right-click the layer in the Contents pane and choose Properties Properties from the context menu.
  3. Click the Source tab on the Layer Properties dialog box.

    The Data Source table contains a property named Query, which displays the current SQL query for the layer.

  4. Click the Edit Query button.

    Open Layer Properties, click Source, and click the Edit Query button.

    The Edit Query Layer dialog box appears.

  5. Alter the SQL query in the first window. Click Validate to ensure your SQL is correct.

    If you defined a materialized view for the query layer, altering and validating the SQL query will re-create the view.

  6. Click Next to change what field or fields are used for the unique identifier or to specify different spatial or layer extent properties for the layer.
    • If you choose Let ArcGIS Pro discover spatial properties for the layer and click Next, values will be prepopulated, but you can change them. Click Finish to save your modifications to the query layer.
    • If you choose Define spatial properties for the layer and click Next, all existing spatial property settings will be cleared, and you must specify new properties. Click Next to set the layer extent, and click Finish to save your modifications to the query layer.

Related topics