Javatpoint Logo
Javatpoint Logo

How to run SQL Script?

What is SQL Script?

The SQL script is a set of commands that saved as a file in SQL Scripts and it contain one or more SQL statements. We use SQL Scripts to create, run, edit, view or delete the script files.

We must remember the following points while using the SQL Scripts:

  • In SQL Scripts, SQL * Plus commands are ignored at the run time.
  • There is no any interaction between SQL Scripts and SQL commands in SQL scripts.
  • We cut and paste SQL commands from SQL script editor.
  • SQL script does not support the bind variables.

Accessing the SQL Scripts

1. First, login to the Workstation.

2. To view the SQL Scripts page, do the following:

  • Click on the SQL Workshop icon and drill-out the SQL page.
  • Click on the down arrow to the right of the SQL Workshop icon to see the drop-down menu after choosing the SQL Scripts option.
    How to run SQL Script

Note: The document used the navigation path (drill-down approach) when we are explaining the navigation for the consistency.

About the SQL Scripts Page

It displays the SQL Scripts that are created by the user. We control the appearance of the page by selecting it from the view list.

The SQL Scripts has three controls:

  • Script. It finds the script by entering the partial name or script name in the script field. It displays the rows by selecting from the display list.
  • Owner. Find the owner of the script you want to see by going to the owner's name and clicking on the owner's name.
  • Opinion. Opinion changes the appearance of SQL Scripts page by selecting the view list.
    • Symbol displays every script as an icon that is identified by script name. Click on the Show Results checkbox to show additional results for icons that are determined by the script name.
    • Description: The description displays each script in one line. Every line has a checkbox to enable the selection process of script. It allows the script to load script name, script editor, and owner of the script. When the script updated in bytes, the text is linked in the run results, and an icon to enable the script to run.

About the Tasks List

The tasks list is displayed on the right side of the page.

How to run SQL Script

The Task List has these points:

  • Task List manages the results and enables the view, search, and display the results.
  • Show Quota: The script quota shows the maximum size of result.
    • Export enables the SQL repository to import the SQL Scripts in the workspace. The scripts are encoded in a single script and is written in local file system. By default export script is "workspace_name_script / sql".
    • Import enables us to import scripts exported by many workspaces.
    • The export script accessible on local file system to import.

Use MySQL workbench to run the SQL script.

How to run SQL Script

To open the SQL Script, go to File -> Open

Alternatively, use the shortcut key Ctrl+Shift+O to open the SQL Script.

Import enables the import scripts exported by the workspace or different workspaces. Import only imports the scripts encoded in export scripts created by using export. The export script will accessible on the local file system for importing.

How to run SQL Script

After browsing .sql files, we select the option Reconnect to database, as we have highlighted in the following image.

How to run SQL Script

It asks for a password to connect with MySQL.

How to run SQL Script

Note: Press the OK button twice to connect with MySQL

After the above process, the SQL files tblstudent appears on the screen that we have uploaded before.

How to run SQL Script

After that, we execute the script by clicking on the symbol highlighted in the following image.

How to run SQL Script

After that, we get the following output:

How to run SQL Script

Deleting Script in the Script Editor

To delete the script, follow the steps given below:

  1. First, click on SQL Workshop and then SQL Scripts on the Workspace home page. The SQL Scripts page appears in the screen.
  2. Open the script which we want to delete in the Script Editor.
  3. Click on the Delete button to remove the script from the Script Repository. We are prompted to confirm the action before the script is deleted.

The message Script(s) deleted shows above the updated list of scripts.

Copying a SQL Script

To save the script, we copy the script in the script repository. Follow the steps given below, to copy a SQL Script.

  1. Click on the SQL Workshop and open SQL Script on the workspace homepage.
  2. Load the script to be copied to the editor.
  3. Enter the name of a copied script into script field.
  4. Click on Save button to save the copy of the script in the script repository field.





Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA