GoLand 2023.2 Help

Virtual views

If you need to monitor the result set of a certain SQL statement that you run regularly, use a virtual view. Virtual view lets you have the result set available in the Database tool window, and that data will not be stored in the database.

For a virtual view, apart from SELECT queries, you can also use statements like show processlist for MySQL or exec sp_who2 for Microsoft SQL Server.

For example, to have a list of current database connections for a PostgreSQL database, create a virtual view with the following query:

SELECT * FROM pg_stat_activity;

The virtual view with the result set of your query will be available in the Database tool window as a virtual object.

Virtual view

Virtual views can be seen in the Database tool window. You can see a reference on node and object icons in the Data sources and their elements chapter of Database tool window topic.

Create a virtual view

  1. In the Database tool window ( View | Tool Windows | Database) , expand the data source tree until the nodes of schemas.

  2. Right-click the schema node and select New | Virtual View.

  3. In the dialog that opens, enter the name of your virtual view in the Name field.

  4. Type your SQL statement in the Query field.

  5. Click OK.

Create a virtual view

The statement is saved in external-data.xml. You can select other name for the XML file and other place to store this file. To change or see the path to the XML document, open data source settings by pressing Command I, click the Options tab and see the Virtual objects and attributes field.

Last modified: 30 June 2023