Skip to content

QueryReuse

Query history

History automatically logs executed SQL queries, allowing you to review, reuse, and manage past queries with ease.

By default, the History feature is disabled. In the DBCode Explorer, open the History view.

History panel in DBCode

Click Enable history to start recording executed SQL queries.

Enable history in DBCode

  1. Open DBCode in Visual Studio Code:

    • Launch Visual Studio Code and click the DBCode icon in the Activity Bar on the left.

    DBCode icon in VS Code

  2. Open the History Panel:

    • In the DBCode sidebar, click the History view to access the list of previously executed queries.

    History panel view

  1. View Past Queries:

    • The History panel shows a chronological list of queries grouped by connection and database.
    • Use the Expand All icon to see all details or the Queries Only icon to show a list of queries from all connections and databases.
    • Apply filters using the Filter icon to narrow your view based on specific criteria.

    Query history list

  2. Re-Run a Query:

    • Click the Load Query icon next to any query to reload it into a new editor tab for the selected database connection.

    Re-run a saved query

  3. Edit and Copy Queries:

    • Use the Copy SQL icon to duplicate a query. Paste it into the editor to modify or use as a new template.

    Copy a query from history

  4. Delete History:

    • To delete a query, click the Delete icon next to it. Confirm the action by selecting “Yes” in the prompt. Individual queries or all queries for a database can be deleted.

    Clear query history

The Active section at the top of the History view lists the queries running right now, from you and from AI agents. Each in-flight query shows a Cancel action, so you can stop a long-running or runaway statement without leaving the editor.

History records whether a query came from you or from an AI agent, along with the client name that issued it (for example, the editor or MCP client). Group history by session and filter it by actor to review exactly what an agent ran against a connection, separately from your own queries. This pairs with AI access roles, which set what an agent is allowed to run in the first place.

  • Time-Saving: Quickly re-run frequently used queries without retyping.
  • Efficient Troubleshooting: Easily review past queries to identify and resolve issues.
  • Organized Workflow: Maintain a comprehensive log of query development for easy reference.

Enabling and using the History can streamline your workflow and make database interactions in Visual Studio Code more efficient and organized.