documentation/getting-started/web-console/code-editor.md
import Screenshot from "@theme/Screenshot"
The Code Editor is the main workspace where you write and execute SQL queries in the QuestDB Web Console. It provides a modern, feature-rich editing experience with syntax highlighting, auto-completion, and multiple query execution mechanisms.
<Screenshot alt="Code Editor in the Web Console" src="images/docs/console/code-editor.webp" />
The Monaco-based editor provides a powerful development environment for writing SQL queries with professional IDE features. It offers syntax highlighting, intelligent auto-completion for database objects, and multiple execution modes to suit different query workflows.
:::info Error markers and the query log are dynamically updated based on cursor position. When you place your cursor within a query, the query log will display the status of that specific query, and error markers will appear if the query execution was previously unsuccessful. :::
Individual query execution offers flexible options for running specific SQL statements within your editor content.
Click the icon in the left margin next to any SQL query to execute it. <Screenshot alt="Run icon variants in the editor" src="images/docs/console/editor-glyphs.webp" height={97} width={307} margin={false} />
The icon provides visual feedback:
When multiple queries exist on the same line, a dropdown menu appears with execution options for each query.
Select a portion of the query in the editor and press Ctrl/Cmd + Enter, or click on the run icon to execute only the selected portion. This allows you to run specific parts of larger queries or test query fragments independently.
:::info When a query is executed with a selection, the selected portion of text is highlighted with a green or red background to indicate the status. You can also track the status from the run icon of the parent query. :::
Right-click on a run icon to access the context menu and select "Get query plan" to see how QuestDB will execute your query. This runs an EXPLAIN command and displays the execution plan in the result grid. See EXPLAIN for details.
The Code Editor supports executing multiple queries in sequence through batch execution. This feature provides two distinct approaches for running multiple queries efficiently.
The editor provides dedicated buttons on the top right for multiple query execution:
<Screenshot alt="Run query dropdown" src="images/docs/console/editor-run-query.webp" height={87} width={279} margin={false} />
Run Query Button:
Ctrl/Cmd + EnterRun All Queries Button:
Ctrl/Cmd + Shift + EnterSelected Queries Mode: When you have multiple queries selected (partially or fully), the system runs only the selected portions of each query in sequence. This allows you to:
All Queries Mode: When you choose "Run all queries", the system executes every query in the tab from top to bottom. This mode includes:
:::tip Running multiple queries is ideal for data migration, bulk operations, or running complex multi-step procedures. The "Stop after failure" option helps prevent cascading errors in critical operations. :::
The Code Editor supports multiple tabs to help you organize and manage different SQL queries simultaneously. Each tab represents a separate query buffer with its own content and execution state.
Click the + button to create a new tab for writing additional queries
Double-click on a tab name to rename it for better organization
Access previously closed tabs and manage your query history
<Screenshot alt="Tab history in the Web Console" src="images/docs/console/tab-history.webp" height={312} width={218} margin={false} />
:::info Web Console maintains a separate query log for each tab. See Query Log for details. :::