Documentation Home
MySQL Shell for VS Code

MySQL Shell for VS Code  /  Database Connections and DB Notebooks  /  Edit a Single-Language Script

Pre-General Availability: 2024-03-25

4.8 Edit a Single-Language Script

In addition to command and query editing, each database connection also supports editing of longer script files written in the SQL, TypeScript, or JavaScript language. Unlike notebook-interface-styled editing, which permits language switching, script editing associated with a database connection supports traditional, single-language script files only.

To edit a new SQL script, TS script, or JS script:

  1. Open the database connection or select an open connection from the Editor list of the toolbar.

  2. From the connection's toolbar, click the file-list icon and select New SQL Script, New TS Script, or New JS Script.

By default, the first editor to open in the connection tab is the notebook-interface-style editor. It is possible to reset this behavior by changing the following extension settings:

  • Set the Msg › Db Editor: Default Editor setting value to script.

  • Set the Msg › Db Editor: Start Language setting value to your preferred scripting language.

To edit an existing SQL script, TS script, or JS script:

  1. Navigate to the script file by selecting the Explorer icon from the activity bar (Ctrl+Shift+E).


    Visual Studio Code might prompt you to set up a folder first.

  2. Right-click the file and select Edit File in MySQL Shell.

  3. When prompted, select a connection for SQL execution. The file opens in the connection tab and the file name appears in the Editor list of the connection's toolbar.

Script editors have many of the same editing features as notebook editors do, although open script files do not facilitate multiple code blocks. Instead, all script editors support standard files that provide line numbers.

The toolbar and the result set capabilities for the script interface are nearly identical to the notebook interface. The following figure shows an open script after it is executed. In this example, the tool generates multiple tabs to display the output and results of the script. You can continue to edit your script after you have executed it.

Figure 4.9 MySQL Shell for VS Code - Single-Language Script

Content is described in the surrounding text.