Once added to ArcMap, the query and other properties that define the query layer can be modified. This is done by opening the Edit Query Layer dialog box, which can be opened from the Layer Properties dialog box.
When a spatial table stored in a database is added to ArcMap, it creates a query layer with default properties as determined by the first row in the table. These properties may not be ideal, however. For example, a spatial table may have multiple geometry types for a single spatial attribute. A spatial table containing a collection of cities can be modeled in the database as both a point and a polygon geometry type. Feature layers in ArcGIS can only have 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 feature layer for cities will be a point geometry type. If you would prefer to view the cities as polygons, you can modify the query layer properties from 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 in the advanced options panel of the Edit Query Layer dialog box and modify them.
When you change the dimensionality of the query layer, the geometry field value of the displayed features are modified to match that change.
For example, for a layer that is defined with x, y, z, and m dimensionality in the database, if you edit the query layer by unchecking the Coordinates include M values and Coordinates include Z values options in the advanced options, all the features in the layer will display only the x and y values. Alternatively, if the layer is defined with only x and y dimensionality (Coordinates include M values and Coordinates include Z values options are unchecked), you can modify the query layer to include m and z values by checking these options, and all the features will display x, y, z, and m values. If 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 advanced options of the Edit Query Layer dialog box, the features displayed in ArcMap are filtered based on that spatial reference or SRID value.
- In the table of contents, right-click the query layer whose query you would like to modify.
- Click Properties to open the Layer Properties dialog box.
- Click the Source tab.
- Click Change Query.
- If you want to change the SQL statement that defines the query layer, modify the query in the Query text box.
See Building a query expression for more information on writing an SQL query in ArcGIS.
- Click Validate to make sure that the query expression is correct.
- If you would like to modify any of the spatial properties of the query layer, such as its dimensionality, SRID, spatial reference, or geometry type, you can click the Show advanced options check box and click Next.
See Creating a query layer for more information on advanced options.
- Click Finish to close the dialog box.
- On the Layer Properties dialog box, click OK to display the new result set for the query layer and close the dialog box.