SQL Editor

The SQL Editor in DBCode provides a powerful environment for working with .sql files, making it easy to write, execute, and manage SQL queries. It offers intelligent features like syntax highlighting, code formatting, autocomplete, and the ability to quickly switch database connections, ensuring a seamless and efficient workflow.

Using the SQL Editor

1. Create or Open a .sql File

  • From the Connections Panel:
    Open the Connections pane in DBCode, select your desired database connection, and click the Create New SQL File icon next to the database.

    Creating a new SQL file from the Connections panel
    Create SQL files directly from your database connection
  • From the File Menu:
    Alternatively, click on the File menu in Visual Studio Code, select New File.

    Creating a new file from the File menu
    Use the standard VS Code File menu to create a new file

    Then set the file name and save it with a .sql extension, and start working.

    Saving a new SQL file
    Save your file with a .sql extension

2. Write SQL Code

  • Begin typing SQL commands to take advantage of syntax highlighting, autocomplete, and error detection.

  • Use features like Autocomplete and Inline Completion for enhanced coding assistance.

3. Format Code

  • Format Entire Document:
    Right-click anywhere in the file and choose Format Document, or use the shortcut Alt+Shift+F.

    Formatting SQL code with right-click menu
    Format your entire SQL document with a single click
  • Format Selected Code:
    Highlight a code block, right-click, and select Format Selection, or use Ctrl+K Ctrl+F (Windows/Linux) or Cmd+K Cmd+F (macOS).

    Formatting selected code
    Format only the selected portion of your SQL code

4. Switch Database Connections

  • Use the dropdown in the code lens at the top of the editor or the status bar to change the active database connection.

  • Easily switch between databases without closing or reopening the file.

    Switching database connections
    Change the active database connection seamlessly

5. Execute Queries and View Results

  • Run Selected Queries:
    Highlight a query and click Execute Selection from the toolbar or right-click and select Execute Selection with DBCode.

  • Run All Queries:
    Click the Execute Query icon at the top-right corner or press Ctrl+Enter to run all queries in the file.

    Executing SQL queries
    Run your SQL queries with ease
  • View Results:
    Query results are displayed in the DBCode Results Panel at the bottom of the editor.

    Viewing query results
    Check your query results in the Results Panel

6. Save and Reuse Queries

  • Save your .sql file with comments and code for future use by going to File > Save in the menu bar.

    Saving SQL files
    Save your SQL files for future use

Benefits of the SQL Editor

  • Flexible Connection Switching: Effortlessly toggle between database connections within a single file.

  • Enhanced Efficiency: Advanced features like autocomplete, syntax highlighting, and formatting speed up the query-writing process.

  • Integrated Workflow: Easily manage and view results within the same editor, ensuring a smooth SQL development experience.

DBCode’s SQL Editor brings an intuitive and feature-rich experience to managing .sql files in Visual Studio Code, empowering users to write and execute SQL commands efficiently while maintaining organized workflows.