The first step in creating a query layer in ArcGIS is to make a connection to the database you want to query. You can do this from the Catalog tree, as explained in Database connections in ArcGIS Desktop. Alternatively, you can connect from the query layer interface in ArcMap, as described below:
- In ArcMap, click File > Add Data > Add Query Layer.
The New Query Layer dialog box opens.
- Click Connections.
The Manage Connection(s) dialog box opens. From here, you can choose existing database connections, create new connections, and edit or delete existing connections.
- Choose an existing connection or create a connection to a database.
- To create a new database connection, click New. The Database Connection dialog box opens. Provide connection information as described in Database connections in ArcGIS Desktop. When the new connection is added to the Existing Connection(s) list, type a descriptive name for the connection and click OK.
- To use an existing connection, choose it from the Existing Connection(s) list and click OK.
A connection to the database must be established before building queries on the New Query Layer dialog box.
You are now connected to the database you chose, and the tables that can be used in your query layer appear in the List of Tables. You are ready to create a query layer.