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.

Click Enable history to start recording executed SQL queries.

Accessing Query History
Section titled “Accessing Query History”-
Open DBCode in Visual Studio Code:
- Launch Visual Studio Code and click the DBCode icon in the Activity Bar on the left.

-
Open the History Panel:
- In the DBCode sidebar, click the History view to access the list of previously executed queries.

Using the History Panel
Section titled “Using the History Panel”-
View Past Queries:
- The History panel shows a chronological list of queries grouped by connection and database.
- Use the
Expand Allicon to see all details or theQueries Onlyicon to show a list of queries from all connections and databases. - Apply filters using the
Filtericon to narrow your view based on specific criteria.

-
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.

-
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.

-
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.

Active queries
Section titled “Active queries”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.
Who ran each query
Section titled “Who ran each query”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.
Benefits of Using Query History
Section titled “Benefits of Using Query History”- 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.