Using the SQL Console

Objective

After completing this lesson, you will be able to open the SQL Console, connect it to a database instance and execute SQL statements

Using the SQL Console

A database administrator needs to be able execute SQL statements on a database. The SAP HANA Cloud Central - SQL Console can be used to run SQL statements directly against the connected database, or let long running statements to be executed in the background.

SAP HANA Cloud Central – SQL Console

The SQL Console within SAP HANA Cloud Central is conveniently located as one of the applications on the navigation panel, which is accessible from anywhere within SAP HANA Cloud Central.

The image shows how to start the SQL Console provided by the SAP HANA Cloud Central, and how to connect it to the database instances you have access to.

The SQL console application is accessible through the navigation panel (1) in SAP HANA Cloud Central. By default, the SQL Console is not connected to a database instance. Click on Select an Instance (2) link to connect to an database instance.

From the Connect Instance pop-up window, choose the desired instance from the presented list (3). Use the search functionality to find the database instance you want to connect.

Note

You can only connect to database instances that you have access permissions to.

Use the Connect with Stored Credentials (4) button to connect with database user credentials that are mapped to you SAP BTP user account.

Use the Connect with Different User (5) button to use a different user account. Using this function requires you to enter the correct username and password combination for the chosen database user.

Running SQL Statements against the selected database schema

Once fully connected to the database instance you are almost ready to run the first SQL statement within the SAP HANA Cloud Central SQL Console.

The image shows how to select a database schema and the different SQL run options.

Choose against which schema (1) you would like to run your SQL statement from the SQL Console. By default the DBADMIN schema is selected, but you can choose any schema where you have the correct access permissions.

In the SQL Editor (2), write out your SQL statement. For example, the statement shown is SELECT * FROM USERS;.

Selecting the Run (3) button will execute the SQL statement within the SQL Console editor. Clicking the down-arrow of the run button will open a drop-down (4) list with the other run options available to execute the SQL statement. the Following run options are available:

Run
Will run the entire batch of SQL statements that’s in the SQL Console editor.
Run Statement

Will run just the first SQL statement.

Run Line

Will only run the selected SQL statement in the SQL Console editor.

Run Statement in Background

Will run the SQL statement as a background activity. This is meant for longer running queries and allows you to do other actions within SAP HANA Cloud Central.

SQL Results, Statement History and Background Statements

When a SQL statement has finished running, the execution results will be shown below the SQL Editor.

The image show the tabs SQL Results, History and Background Statements.

the output the executed SQL provides. The output is already aligned per column. Clicking on a column header will show the options to sort Ascending, Descending, or filter on a specific value.

The History (2) tab shows all SQL statements run in this SQL Editor session. The history tab provides information on which statement was run at what time, how many rows were selected, the execution elapsed time, the execution CPU time, the memory usage, and whether or not the statement ran successful.

The Background Statements (3) tab shows which statements were executed at what time in the background.