PUBLIC SAP HANA Database Explorer 2.0 SP 12 Document Version: 1.0 – 2020-05-14
SAP HANA Database Explorer company. All rights reserved. affiliate
THE BEST RUN 2020 SAP SE or an SAP © Content
1 Getting Started With the SAP HANA Database Explorer...... 4 1.1 What's New in SAP HANA Database Explorer...... 5 1.2 Open Catalog Objects...... 8 1.3 Create URL Shortcuts to Database Objects in the SAP HANA Database Explorer...... 9 1.4 Search for Database Objects in the SAP HANA Database Explorer...... 9 1.5 Add a Database to the SAP HANA Database Explorer...... 10 1.6 Add HDI Containers and Databases to the SAP HANA Database Explorer...... 13
2 Security in the SAP HANA Database Explorer...... 17 2.1 Data Protection in SAP HANA Database Explorer...... 17 Delete Personal Data...... 19 Delete Your Personal Data...... 21 2.2 Securing the SAP HANA Database Explorer...... 22 Secure the SAP HANA Database Explorer from Web Socket Attacks...... 23
3 Analyzing and Diagnosing Errors...... 25 3.1 Set Session Logging...... 25 3.2 View SQLScript Code Coverage Report...... 26 3.3 View Database Procedures in the SAP HANA Database Explorer...... 27 Debug Procedures in the SAP HANA Database Explorer...... 27 3.4 SAP HANA Database Explorer Debugger Tutorials...... 29 Tutorial: Connecting the Debugger...... 30 Tutorial: Debugging a Procedure by Setting Breakpoints...... 31 Tutorial: Debugging a Function by Setting Breakpoints...... 32 Tutorial: Debugging an Anonymous Block...... 33 Tutorial: Debugging a SQLScript Library...... 34 Tutorial: Working With Expressions in the Debugger...... 34 Tutorial: Working with Variables in the Debugger...... 35 Tutorial: Working With Watchpoints in the Debugger...... 36 Tutorial: Quitting the Debugging Session...... 37
4 Querying the Database...... 39 4.1 Execute SQL Statements...... 40 4.2 Execute Parameterized Statements...... 42 4.3 Run a Query as a Background Activity...... 43 4.4 Use the Statement Library to Administer Your Database ...... 44 4.5 Work With Graph Workspaces in SAP HANA Database Explorer...... 46
SAP HANA Database Explorer 2 PUBLIC Content 5 Analyzing Performance...... 48 5.1 Configure Tracing in the SAP HANA Database Explorer...... 48 5.2 View Diagnostic Files in the SAP HANA Database Explorer...... 49 Viewing the Trace File List...... 50 View Diagnosis Files of an Unavailable Tenant Database...... 50 5.3 Traces...... 51 Database Trace (Basic, User-Specific, and End-to-End)...... 53 SQL Trace...... 58 Performance Trace...... 62 Expensive Statements Trace...... 63 Kernel Profiler...... 66 Traces and Trace Configuration for Internal Web Dispatcher...... 68 5.4 Analyzing Statement Performance...... 70
Analyze Statement Performance...... 72 5.5 Analyzing SQL and Saving Plans...... 76 Save Plans as Files...... 76 Download Files...... 78 5.6 Analyze Procedure and Function Performance...... 79 5.7 View Execution Plans for SQL Statements, Procedures, and Anonymous Blocks...... 80
6 View Diagnostic Files in the SAP HANA Database Explorer...... 81 6.1 Viewing the Trace File List...... 82 6.2 View Diagnosis Files of an Unavailable Tenant Database...... 82
7 Importing, Exporting, and Accessing Data...... 84 7.1 Create a Remote Source...... 84 Edit a Remote Source...... 86 7.2 Edit a Remote Source...... 87 7.3 Create Virtual Objects (Smart Data Access)...... 88 7.4 Create Virtual Objects (SAP HANA Smart Data Integration)...... 89 7.5 Import Schemas, Tables, and Other Catalog Objects...... 90 7.6 Import Data Into a New or Existing Table...... 91 7.7 Import HDI Containers...... 93 7.8 Export Schemas, Tables, and Other Catalog Objects ...... 94 7.9 Export HDI Containers...... 96
8 Important Disclaimer for Features in SAP HANA...... 98
SAP HANA Database Explorer Content PUBLIC 3 1 Getting Started With the SAP HANA Database Explorer
Use the SAP HANA database explorer to query information about the database, as well as view information about your database's catalog objects.
The database explorer is integrated into both the SAP Web IDE for SAP HANA and in the SAP HANA cockpit. The database explorer contains features and functions required by both database administrators and developers.
What can I do with the SAP HANA database explorer?
The SAP HANA database explorer allows you to query your database and view information about your catalog objects, by providing the following functionality:
A catalog browser View the definitions of all types of catalog objects, for example: tables, views, stored procedures, functions, and synonyms. Also, view the content (data) of your tables and views.
An SQL console Create SQLScript procedures and queries, and then execute them or analyze their performance using the SQL analyzer.
An SQL analyzer View detailed information on your queries and evaluate potential bottlenecks and optimizations for these queries. The SQL analyzer is accessible from the SQL console, as well as from the plan trace and expensive statement features in the SAP HANA cockpit.
An SQL debugger View the call stack, set break points, view and evaluate expressions and variables.
Related Information
SAP Note 2373065
SAP HANA Database Explorer 4 PUBLIC Getting Started With the SAP HANA Database Explorer 1.1 What's New in SAP HANA Database Explorer
The following features are new or changed for this release of SAP HANA database explorer.
Change a Database You can now change the name that is displayed for your database in the catalog Name (New) browser tree. Right-click your database and click Properties, then edit the Name to Show in Display field.
Add a Database When adding a cockpit database to the database explorer, you can now choose to enter a With a Different User and Password that is different than that provided in the cockpit for that database. User (New) Moreover, once you've added a database to the database explorer, you can go back later and re-add it with different user credentials by right-clicking the database and clicking Add Database with Different User.
See Add a Database to the SAP HANA Database Explorer [page 10]
SQL Console ● The SQL Console page of the Global Preferences contains the following new options: (Enhancements) On error Allows you to control the behavior of the SQL console when it encounters a SQL error. You can choose the following actions: Stop, Continue, or Prompt.
Command If your SQL statements contain a custom command separator, then Separator set the custom separator in the SQL Console section of the Global Preferences so that the parser recognizes your command separator. Command separators differ from statement delimiters in that they separate commands, which can be either a single-line SQL statement or a block of SQL statements that are separated by their own statement delimiter.
● A new History tab has been added to the SQL console. This tab shows the 50 most recently executed statements. For more information, see Querying the Database [page 39]. ● Statement Use the new SQL console side panel to access syntax for SQL Help (New) statements and to view metadata SQL objects. You can view the following information:
Statement/ View the syntax of the statement you are Syntax currently editing and use the statement link to access full reference documentation for the statement.
Tables and View information on the tables or views being Views referenced in the current statement and use the title link to open the table or view definition.
Procedures and View information on procedures or functions Functions being referenced in the current console and use the link to open the procedure or function definition.
SAP HANA Database Explorer Getting Started With the SAP HANA Database Explorer PUBLIC 5 SQL Functions View information on built-in functions and use the link to access full reference documentation for the function.
Import Catalog If you are including object data when importing a catalog object, you now have the Objects option of selecting Fail import if it contains invalid data. Selecting this checkbox on the (Enhancement) Import Catalog Objects dialog ensures that your import is canceled if any of the object data is incomplete or corrupt.
See Import Schemas, Tables, and Other Catalog Objects [page 90].
Table Editor The table editor now contains a Runtime Information tab that displays general (Enhancement) information and information about memory and disk usage, as well as partitions, and columns.
Database Right-click a database in your catalog browser and click Show Overview to view general Overview information about your database such as information about Disk Usage,Used Memory, (New) Resident Memory, CPU Usage, system usage type, the most recently started service, and the version.
In SAP Web IDE, the Overview tab is not available for HDI containers.
Column Views When searching for column views, you can now select the filter icon to filter your results (Enhancement) by Calculation Views, Calculation Views and User-Defined Hierarchies, or All.
Smart Data The following enhancements have been made to SDI catalog objects: Integration Adapters (Enhancements) On the Adapters overview page, use the new Reload button to update your selected adapter, or use the new Remove Location button to remove the adapter from an agent instance.
Agents You can now create, edit, and drop agents from the Agents overview page.
You can also add an adapter for your agent by clicking the new Add Adapter button in the Agents overview page when you have an agent selected.
Agent Groups You can now create and drop agents from the Agent Groups overview page.
You can also add an agent to your agent group by clicking the new Add Agent button in the Agent Groups overview page when you have an agent selected.
Remote The Remote Subscriptions tab for SDI remote subscriptions now Subscriptions allows to Queue, Distribute, Reset, and Drop the remote (Enhancements) subscription.
Tasks For SDI tasks, you can now execute a task and cancel a running (Enhancements) task in the Tasks tab.
SAP HANA Database Explorer 6 PUBLIC Getting Started With the SAP HANA Database Explorer Remote As part of an SDI task execution, you can now see the remote Statements statements that were executed. Click on a task in the catalog browser to view the task's details, then click on either a completed execution or the specific partition of a completed execution and click the Remote Statements button to view remote statements for the task.
You can also choose to stop the task once it has started.
For more information about SDI and the privileges required to work with SDI objects, see the SAP HANA Smart Data Integration and SAP HANA Smart Data Quality guide.
Tracing Expensive When configuring expensive statements trace, you can now (Enhancements) Statements Trace configure the following settings: (Enhancement) ● CPU Threshold ● Memory Threshold ● Table or View Filter ● Store Trace Information ● In-Memory Tracing Records ● Trace Flush Interval
Viewing Diagnostic To view a diagnostic file in an editor, you now right-click the file and Files click Show Files in the context menu. (Enhancement) Binary trace files are now identified in the catalog browser by a binary icon and you can no longer open binary trace files from the catalog browser. Binary trace files can only be downloaded.
Trace files have also been enhanced to be more user-friendly by containing the following information in their tooltips:
● the full file name ● the file size ● the last modified time
Performance You can now configure performance tracing in the database Tracing (New) explorer.
See Performance Trace [page 62] and Configure Tracing in the SAP HANA Database Explorer [page 48], View Diagnostic Files in the SAP HANA Database Explorer [page 49].
SAP HANA Database Explorer Getting Started With the SAP HANA Database Explorer PUBLIC 7 1.2 Open Catalog Objects
Browse your database's catalog using the SAP HANA database explorer.
Prerequisites
You must be a user of the database that you want to explore and you must have the required privileges to view the catalog items.
Context
Some monitoring and problem analysis may require you to examine individual tables and views, for example, system views provided by the SAP HANA database. Use the catalog browser, which is located in the left pane, to find and open these catalog objects.
Procedure
1. In the catalog browser, choose the database that you want to explore.
If your database is not listed in the catalog browser, then click Add a database to the Database Explorer () to add the database.
The catalog browser lists the catalog objects, grouped by schema. 2. Choose an object type to view its objects.
For example, choose Tables to list the tables in the database. 3. Choose an object to view its definition in an editor in the right pane, or right-click the object to choose a different action.
For example, right-click a table and choose Open Data to view the table's data.
Related Information
Add a Database to the SAP HANA Database Explorer [page 10] Add HDI Containers and Databases to the SAP HANA Database Explorer [page 13] View Database Procedures in the SAP HANA Database Explorer [page 27]
SAP HANA Database Explorer 8 PUBLIC Getting Started With the SAP HANA Database Explorer 1.3 Create URL Shortcuts to Database Objects in the SAP HANA Database Explorer
Use the SAP HANA database explorer to create a URL shortcut, and then use it to create a bookmark or favorite in your browser.
Procedure
1. In the catalog browser, right-click a database object and choose Create Shortcut. 2. Click Copy URL to copy the shortcut to your clipboard. 3. Paste the URL into your browser. 4. Use your browser to create a bookmark or favorite for the copied URL.
Results
The shortcut is created. Use it to open the database explorer and quickly navigate to the database object.
Related Information
Search for Database Objects in the SAP HANA Database Explorer [page 9]
1.4 Search for Database Objects in the SAP HANA Database Explorer
Search for database objects across all databases that the SAP HANA database explorer is connected to.
Prerequisites
In the database explorer, connect to each database that you want to search.
SAP HANA Database Explorer Getting Started With the SAP HANA Database Explorer PUBLIC 9 Context
Use the catalog browser to find your object when you know the type of object and the database that it exists in.
If you are unsure of the object type or the database that it exists in, then use the database object search. This search looks for matches in either a specified database or all of the connected databases in the database explorer and it can search across more than one object type. For example, use this search to find all tables and procedures that contain the word production in their names.
Procedure
From the right sidebar of the database explorer, click Object Search (). a. Specify a search term that is longer than one character.
Specify * to return all results. b. Optionally, restrict your search to a specific database. c. Target your search to specific object types by selecting them at the bottom of the pane.
Results
The search results appear in the Search for Database Objects pane.
Related Information
Create URL Shortcuts to Database Objects in the SAP HANA Database Explorer [page 9] Open Catalog Objects [page 8]
1.5 Add a Database to the SAP HANA Database Explorer
Add a database to the SAP HANA database explorer so that you can browse its catalog and execute SQL statements against it.
Context
Adding a database to the database explorer is similar to registering a database in the cockpit. Once a database is added, it is listed in the catalog browser pane on the left.
SAP HANA Database Explorer 10 PUBLIC Getting Started With the SAP HANA Database Explorer You cannot add a database to the database explorer that uses LDAP authentication.
Procedure
1. Open the database explorer from the SAP HANA cockpit. 2. Add a database by clicking the Add a Database to the Database Explorer icon () at the top of the catalog browser pane on the left. 3. From the Database Type dropdown list, choose the type of database to add:
Database Type Action
Add a database 1. Choose Cockpit Database. that has been reg 2. Choose a resource from the list. istered in the cock pit 3. Choose to either use the credentials supplied in the cockpit, or to enter a different user name or password.
An SAP HANA da 1. Choose SAP HANA database. tabase 2. Specify the fully qualified domain name (FQDN) of the host on which the system is installed. Specify the instance number or port of the database you are adding. When adding a database that is part of a multi-host system, specify the master host. You do not have to enter all host names explicitly as they are determined automatically. If the master host becomes unavailable, then the connection is automatically established through one of the other hosts. Hosts that are added to the system later are also detected automatically.
A tenant or the 1. Choose SAP HANA database (Multitenant). system database 2. Specify the host and instance number or port of the system database. that is part of a multitenant data 3. Specify whether you are adding the system database or a tenant database. If you are adding base container sys a tenant database, then specify the name of the tenant database. tem
4. (Optional) If you are adding an SAP HANA database, a tenant database, or a system database that is part of a multi-tenant database container system, then specify encryption information and advanced connection properties as required.
Choose from the following encryption options:
Option Description
Save user and password (stored in the SAP HANA secure By default, your database credentials are not saved. Each store.) time you need to connect to an added database, you must provide your user credentials.
Choose this option to save these user credentials so that you do not have to re-enter them each time you connect. These credentials are saved to the SAP HANA secure store.
SAP HANA Database Explorer Getting Started With the SAP HANA Database Explorer PUBLIC 11 Option Description
Connect to the database securely using TLS/SSL. Choose this option to encrypt communication between (Prevents data eavesdropping.) the database explorer and the SAP HANA database using the Transport Security Layer (TLS)/Secure Sockets Layer (SSL) protocol.
Verify the server's certificate using the trusted certificate Choose the Verify the server's certificate using the trusted below. certificate below option and provide a trusted certificate, if you want to verify the server's certificate when connect ing. This prevents server impersonation. The certificate field must contain the contents of a certificate, and not a file name. For more information, see the SAP HANA Secur ity Guide.
Note
You can only choose this option if you have also chosen the Connect to the database securely using TLS/SSL. (Prevents data eavesdropping.) option.
Choose from the following advanced options.
In the Advanced Options field, specify the advanced options as semi-colon-separated name=value pairs. For example: locale=en-US, isolationLevel=READ COMMITTED.
Option Description
isolationLevel The isolation level for the connection. The supported val ues are: READ COMMITTED, REPEATABLE READ, and SE RIALIZABLE. The default is to specify no isolation level.
locale The locale to use for the connection. If you do not set this option, then the database explorer looks for a locale set ting in your user parameter, and then in your browser. If no locale setting is found, then the locale is set to en-US.
schema The name of the schema that you want to use
CLIENT Sets the session client for the connection. The value is a three character string. For example, CLIENT=100.
5. (Optional) Choose a display name that is used to identify your database in the database explorer. Each database must have a unique display name. If you do not choose a display name, then one is generated for you. 6. Click OK.
SAP HANA Database Explorer 12 PUBLIC Getting Started With the SAP HANA Database Explorer Results
The database is added to the database browser.
Next Steps
After adding a cockpit database, you can always go back and re-add the database with different user credentials. Just right-click the cockpit database and click Add Database with Different User.
Related Information
Securing the SAP HANA Database Explorer [page 22] Open Catalog Objects [page 8] Execute SQL Statements [page 40]
1.6 Add HDI Containers and Databases to the SAP HANA Database Explorer
Add a built HDI container to the SAP HANA database explorer in the SAP Web IDE for SAP HANA , so that you can browse its catalog objects and test its procedures and functions.
Prerequisites
The HDI container must be configured on the same XS advanced server that the SAP Web IDE is running on.
To add an SAP HANA database to the database explorer, you must have a user ID and a password for that database.
You must be a space developer of the space that the HDI container is deployed in.
You must be a user of the SAP Web IDE for SAP HANA.
Context
Once an HDI container or database is added to the database explorer, it is listed in the catalog browser pane on the left.
You cannot add a database to the database explorer that uses LDAP authentication.
SAP HANA Database Explorer Getting Started With the SAP HANA Database Explorer PUBLIC 13 Procedure
1. Open the database explorer from the SAP Web IDE by choosing Tools Database Explorer . 2. Add a database by clicking the Add a database to the Database Explorer icon () from the catalog browser toolbar. 3. From the Database Type dropdown list, choose the type of database to add:
Database Type Action
1. Choose HDI container. An HDI container 2. Choose an HDI container from the list. The list contains all HDI containers used by the SAP Web IDE and the database explorer as well as all user-defined HDI containers. 3. Set the XS_APPLICATIONUSER session variable to make the connection personalized for the current user.
1. Choose SAP HANA database. An SAP HANA data 2. Specify the fully qualified domain name (FQDN) of the host on which the system is instal base led. Specify the instance number or port of the database you are adding. When adding a database that is part of a multi-host system, specify the master host. You do not have to enter all host names explicitly as they are determined automatically. If the master host becomes unavailable, then the connection is automatically established through one of the other hosts. Hosts that are added to the system later are also detected automatically.
A tenant or the sys 1. Choose SAP HANA database (Multitenant). tem database that is 2. Specify the host and instance number or port of the system database. part of a multitenant database container 3. Specify whether you are adding the system database or a tenant database. When adding system a tenant database, specify the name of the tenant database.
HDI containers con 1. Choose Application Managed Service Instances. tained in instance 2. Specify the instance manager that contains the HDI container you want to add. managers 3. Choose an HDI container from the list. The list contains all HDI containers used by the SAP Web IDE and the database explorer as well as all user-defined HDI containers. 4. Set the XS_APPLICATIONUSER session variable to make the connection personalized for the current user.
4. (Optional) Specify advanced connection properties as required.
SAP HANA Database Explorer 14 PUBLIC Getting Started With the SAP HANA Database Explorer Choose from the following encryption options:
Option Description
Save user and password (stored in the SAP HANA secure By default, your database credentials are not saved. Each store) time you need to connect to an added database, you must provide your user credentials.
Choose this option to save these user credentials so that you do not have to re-enter them each time you connect. These credentials are saved to the SAP HANA secure store.
Connect to the database securely using TLS/SSL. Choose this option to encrypt communication between (Prevents data eavesdropping.) the database explorer and the SAP HANA database using the Transport Security Layer (TLS)/Secure Sockets Layer (SSL) protocol.
Verify the server's certificate using the trusted certificate Choose the Verify the server's certificate using the trusted below. certificate below option and provide a trusted certificate, if you want to verify the server's certificate when connect ing. This prevents server impersonation. The certificate field must contain the contents of a certificate, and not a file name. For more information, see the SAP HANA Secur ity Guide.
Note
You can only choose this option if you have also chosen the Connect to the database securely using TLS/SSL. (Prevents data eavesdropping.) option.
In the Advanced Options field, specify the advanced options as a semi-colon-separated, option- name=value pair. For example: locale=en-US, isolationLevel=READ COMMITTED.
Option Description
isolationLevel The isolation level for the connection. The supported val ues are: READ COMMITTED, REPEATABLE READ, and SE RIALIZABLE. The default is to specify no isolation level.
locale The locale to use for the connection. If you do not set this option, then the database explorer looks for a locale set ting in your user parameter, and then in your browser. If no locale setting is found, then the locale is set to en-US.
schema The name of the schema that you want to use
CLIENT Sets the session client for the connection. The value is a three character string. For example, CLIENT=100.
5. Click OK.
SAP HANA Database Explorer Getting Started With the SAP HANA Database Explorer PUBLIC 15 Results
The HDI container or database is added to the database browser.
By default, you are connected to the HDI container as the technical user.
Related Information
Open Catalog Objects [page 8] Execute SQL Statements [page 40]
SAP HANA Database Explorer 16 PUBLIC Getting Started With the SAP HANA Database Explorer 2 Security in the SAP HANA Database Explorer
The database explorer supplies secure authentication, authorization, and connections and provides a simple method to delete personal information as needed.
2.1 Data Protection in SAP HANA Database Explorer
Data protection is associated with numerous legal requirements and privacy concerns. In addition to compliance with general data privacy regulation, it is necessary to consider compliance with industry-specific legislation in different countries. SAP provides specific features and functions to support compliance with regards to relevant legal requirements, including data protection. SAP does not give any advice on whether these features and functions are the best method to support company, industry, regional, or country-specific requirements. Furthermore, this information does not give any advice or recommendation in regards to additional features that would be required in particular IT environments; decisions related to data protection must be made on a case-by-case basis, under consideration of the given system landscape and the applicable legal requirements.
Note
In the majority of cases, compliance with applicable data protection and privacy laws will not be covered by a product feature. SAP software supports data protection compliance by providing security features and specific data protection-relevant functions, such as simplified blocking and deletion of personal data. SAP does not provide legal advice in any form. Definitions and other terms used in this document are not taken from any given legal source.
Glossary
Term Definition
Consent The action of the data subject confirming that the usage of his or her personal data shall be allowed for a given purpose. A consent functionality allows the stor age of a consent record in relation to a specific purpose and shows if a data sub ject has granted, withdrawn, or denied consent.
Deletion The irreversible destruction of personal data.
SAP HANA Database Explorer Security in the SAP HANA Database Explorer PUBLIC 17 Term Definition
Personal data Any information relating to an identified or identifiable natural person ("data sub ject"). An identifiable natural person is one who can be identified, directly or indi rectly, in particular by reference to an identifier such as a name, an identification number, location data, an online identifier or to one or more factors specific to the physical, physiological, genetic, mental, economic, cultural, or social identity of that natural person.
Purpose A legal, contractual, or in other form justified reason for the processing of per sonal data. The assumption is that any purpose has an end that is usually already defined when the purpose starts.
Collection of Personal Data
SAP HANA database explorer stores only personal data entered by users; it never collects personal data without a user's knowledge. The only personal information stored by the SAP HANA database explorer consists of the following:
XSA user The XSA user ID is received from the XSA or Cloud Foundry login page and is recorded in both the ID SAP HANA database explorer and in log files. The following information associated with the user ID is also stored in the SAP HANA database explorer:
User-Defined SQL Statements User-defined SQL statements are associated with a specific user and may contain personal data.
Long-Running SQL Queries These queries are associated with a specific user and may contain personal data.
User ID for Cloud Foundry This ID is retained only until WebIDE is restarted or upgraded. Login When Connecting to the Database Explorer from WebIDE
Database Credentials User credentials associated with a specific user for HANA databases are stored in the SAP HANA database explorer.
User Preferences These preferences are associated with a specific user and are stored in the SAP HANA database explorer.
Logging SAP HANA database explorer collects XSA logs (when running on premise), Cloud Foundry logs (when running on SCP), and audit logs. Audit logs can track read access and changes and may contain user-specific data.XSA logs are retained indefinitely by XSA. For more information about XSA logging, see the SAP HANA Developer Guide for XS Advanced Model. Cloud Foundry logs are retained for one week. Audit logs cannot be deleted.
By default, logging is set to an application-wide level that does not record any personal data. However, you can set logging to session level, which collects all SQL statements for the current session. These statements may contain personal data.
SAP HANA Database Explorer 18 PUBLIC Security in the SAP HANA Database Explorer 2.1.1 Delete Personal Data
Delete user-specific information that is stored by the SAP HANA database explorer.
Context
This procedure deletes the following personal data that is associated with the specified user ID:
● All database credentials ● All user-defined SQL statements ● All user preferences ● All background tasks ● All content in open SQL consoles
Procedure
1. Using the xs command-line utility to log in as a user with the SpaceDeveloper role to the organization and space where the database explorer is installed.
For example, in SAP HANA Express, the command looks similar to the following:
xs login -a https://hxehost:39030 -o HANAExpress -s SAP -u XSA_ADMIN
2. Run the xs env hrtt-service command to find the connection parameters for the hrtt-datasource. Search the command results for the credentials with path VCAP_SERVICES.hana[0].
The results are similar to the following:
{
"name": "hrtt-datasource", "label": "hana", "tags": [ "hana", "database", "relational" ], "plan": "securestore", "credentials": { "schema": "USR_BTVXBP585K74Z43VYJBW8WWZU", "password": "password", "driver": "com.sap.db.jdbc.Driver", "port": "port-number", "host": "hxehost", "db_hosts": [ { "port": 39013, "host": "hxehost" } ], "user": "USR_BTVXBP585K74Z43VYJBW8WWZU", "url": "jdbc:sap://hxehost:39013/? currentschema=USR_BTVXBP585K74Z43VYJBW8WWZU" }
SAP HANA Database Explorer Security in the SAP HANA Database Explorer PUBLIC 19 }
3. Open the database explorer from the SAP HANA cockpit or SAP Web IDE for HANA and add a database by using the values from the hrtt-datasource entry above. a. Click the Add a Database to the Database Explorer icon () and choose either SAP HANA Database (Multitenant) or SAP HANA Database (if you have a single database container). b. Determine the instance number from the hrtt-service environment port field value. If the port number is 3
DO ( IN user_id VARCHAR(56) => '
BEGIN DECLARE c INT; DECLARE v_sql VARCHAR(1000); SELECT COUNT(*) INTO c FROM SYS.TABLES WHERE schema_name=current_schema AND ( table_name='ACTIVITY_RESULTS' or table_name='ACTIVITIES_' ); IF c = 2 THEN v_sql = 'DELETE FROM ACTIVITY_RESULTS AR WHERE AR.ACTIVITY_ID IN ( SELECT ACTIVITY_ID FROM ACTIVITIES_ A
WHERE A.USER_ID = ''' || :
exec :v_sql; END IF; SELECT COUNT(*) INTO c FROM SYS.TABLES WHERE schema_name=current_schema AND table_name='ACTIVITIES_'; IF c = 1 THEN
v_sql = 'DELETE FROM ACTIVITIES_ WHERE USER_ID = ''' || :
exec :v_sql; END IF; SELECT COUNT(*) INTO c FROM SYS.TABLES WHERE schema_name=current_schema AND table_name='STATEMENTS'; IF c = 1 THEN
v_sql = 'DELETE FROM STATEMENTS WHERE OWNER = ''' || :
exec :v_sql; END IF; SELECT COUNT(*) INTO c FROM SYS.TABLES WHERE schema_name=current_schema AND table_name='USER_DATABASE_LOCKS'; IF c = 1 THEN
v_sql = 'DELETE FROM USER_DATABASE_LOCKS WHERE USERID = ''' || :
exec :v_sql; END IF; SELECT COUNT(*) INTO c FROM SYS.TABLES WHERE schema_name=current_schema AND table_name='USER_DATABASES'; IF c = 1 THEN
v_sql = 'DELETE FROM USER_DATABASES WHERE USERID = ''' || :
exec :v_sql; END IF; SELECT COUNT(*) INTO c FROM SYS.TABLES WHERE schema_name=current_schema AND table_name='USER_PREFERENCES'; IF c = 1 THEN
v_sql = 'DELETE FROM USER_PREFERENCES WHERE USERID = ''' || :
exec :v_sql; END IF; SELECT COUNT(*) INTO c FROM SYS.TABLES WHERE schema_name=current_schema AND table_name='XRAY_STORIES'; IF c = 1 THEN
SAP HANA Database Explorer 20 PUBLIC Security in the SAP HANA Database Explorer v_sql = 'DELETE FROM XRAY_STORIES WHERE CREATED_BY = ''' || :
exec :v_sql; END IF; COMMIT; END;
Results
The data for the specified user is removed from the tables in hrtt-datasource.
2.1.2 Delete Your Personal Data
Delete your personal information stored by the SAP HANA database explorer.
Context
This procedure deletes the following personal data associated with the connected user ID:
● All database credentials ● All user-defined SQL statements ● All user preferences ● All background tasks ● All content in open SQL consoles
Procedure
1. Click the Preferences icon () and click Database Explorer. 2. Click Remove all user data then click Yes.
Results
Your user data is deleted and SAP HANA database explorer restarts.
SAP HANA Database Explorer Security in the SAP HANA Database Explorer PUBLIC 21 2.2 Securing the SAP HANA Database Explorer
Security considerations for SAP HANA database explorer include authentication, authorization, and secured connections.
Authentication and Authentication and authorization for the database explorer is governed by the authorization application in which it resides.
The database explorer is integrated into SAP HANA cockpit and SAP Web IDE for SAP HANA. To use the database explorer you must be a non-administrator user of one of these applications.
Access to As a cockpit user, you can access any HDI container that exists in a registered space in which you have been assigned the SpaceDeveloper role. cockpit databases As a cockpit user, you can access any cockpit that is assigned to a group of which you are a member.
Access to HDI As an SAP Web IDE user, you can access any HDI container that is containers in configured to run on the same XS advanced server that SAP Web IDE SAP Web IDE runs on, and that exists in a space in which you have been assigned the SpaceDeveloper role.
By default, an HDI container user is assigned a few basic database privileges. For example, the object owner (“#OO” user) is only assigned the CREATE ANY privilege on the container's run-time schema (schema “TEST” for an HDI container “TEST”). To access database objects inside other database schemata or other HDI containers, and to be able to deploy synonyms into the HDI container that point to objects outside the container, or to be able to import catalog objects into an HDI container, you must grant the object owner additional privileges.
For more information see the SAP HANA Developer Guide (For SAP HANA XS Advanced Model).
Connections from As a user of the cockpit, you can add any registered database to the database explorer. the browser to the When the database browser sends a connection request to the XS advanced server that database explorer is associated with the database explorer, the browser verifies that the host name of the XS advanced server responding XS advanced server matches the host name that it provides. Specifically the browser includes the Origin header, which contains the host name of the XS advanced server in the request. If the host name of the responding XS advanced server does not match the host name in the Origin header, then the connection does not proceed. You can provide the XS advanced server with a list of host names to use during this verification by setting the WEBSOCKET_ORIGIN environment variable (using xs set - env) for the XS advanced server.
TLS/SSL Specify the root certificate when you add a database that supports TLS/SSL connections from connections with certificates to the database explorer. SAP HANA databases that the database accept TLS/SSL connections usually use certificates that are obtained from a
SAP HANA Database Explorer 22 PUBLIC Security in the SAP HANA Database Explorer explorer to Certification Authority (CA), but you can use your own signed certificates. To create a databases signed certificate, perform the following steps:
1. Create a self-signed root certificate. 2. Create a second certificate that is signed by the root certificate 3. Provide the second, signed certificate to the database server. 4. Provide the root certificate to your clients (such as the database explorer).
Storing database When you specify the credentials to connect to an SAP HANA database, those user credentials credentials are not saved to your browser. To have the credentials persist between sessions, save the credentials to the SAP HANA secure store.
Saving SQL console If your browser supports saving content to local storage, then, for the duration of your information to your session, the SQL content in your SQL console is saved to your browser. (Configure this browser's local behavior in your user preferences within the SAP Web IDE.) storage
Exporting and When you export catalog objects, the content that is saved is not encrypted. importing catalog objects When you import catalog objects into a database, no automatic virus scan or content validation of the files is performed before they are imported. Malicious content can be imported. Use external tools to validate the content of the files and scan them for viruses before importing them.
Related Information
Getting Started With the SAP HANA Database Explorer [page 4] Secure User Store (hdbuserstore) Permissions for Container Objects Known Security-Related Issues
2.2.1 Secure the SAP HANA Database Explorer from Web Socket Attacks
When the host name in the URL for the SAP Web IDE for SAP HANA or SAP HANA cockpit does not match the hostname of its XS advanced server, then you must provide the XS advanced server with the accepted host names to use when the XS advanced server verifies connections to the SAP HANA database explorer.
Prerequisites
You must have one of the following roles:
● OrgManager
SAP HANA Database Explorer Security in the SAP HANA Database Explorer PUBLIC 23 ● SpaceManager ● SpaceDeveloper
Procedure
1. Connect to the XS command line interface.
For example:
xs login -a https://myhostname.mycorporatesite.com:30030 -u XSA_ADMIN -p mypassword
2. Set the WEBSOCKET_ORIGIN environment variable for the XS advanced server to the list of acceptable host names. Use the set-env command and enclose the acceptable host names between square brackets.
On a Unix system, the value must be enclosed in single quotes. For example:
xs set-env hrtt-service WEBSOCKET_ORIGIN '["myhost1", "myhost2"]'
On Windows, the double quote characters must be escaped. For example:
xs set-env hrtt-service WEBSOCKET_ORIGIN [\"myhost1\",\"myhost2\"]
3. Execute the following commands to restage the hrtt-service.
xs restage hrtt-service
4. Execute the following commands to restart hrtt-service.
xs restart hrtt-service
SAP HANA Database Explorer 24 PUBLIC Security in the SAP HANA Database Explorer 3 Analyzing and Diagnosing Errors
The SAP HANA database explorer allows you to configure different types of traces and view diagnostic files for your database. You can also use the SQL debugger to ensure that your database queries are error-free.
3.1 Set Session Logging
Log all back-end service requests for the specific user session.
Context
Set user-specific session logging when you require debug traces for individual requests, for example to provide to your cloud administrator for support purposes, but you do not want to expose sensitive data from other users.
Session-based logging records all SQL statements executed during the database explorer session as well as their result sets. These SQL statements may contain personal data.
Procedure
1. Click the Preferences icon () and click Database Explorer. 2. Click Debug Logging, confirm the logging changes, then click Save.
Results
Debug logging is now active only for the connected user for the duration of the SAP HANA database explorer session.
SAP HANA Database Explorer Analyzing and Diagnosing Errors PUBLIC 25 3.2 View SQLScript Code Coverage Report
Retrieve code coverage information for SQLScript procedures, functions, and anonymous blocks.
Prerequisites
To see a database object in the coverage report, you must have the DEBUG object privilege for that object.
You must have a minimum database version of HANA 2.0.030.
Context
Information is provided for code executed within one user-provided SQL session.
Procedure
1. Enter your procedure, function, or anonymous block into the SQL console.
2. Click ANALYZE Report Code Coverage .
Results
The code is executed and a coverage report is generated and is displayed under the Code Coverage Report tab. The Overview table of the code coverage report contains one row per procedure/function/anonymous block involved in the code execution.
SAP HANA Database Explorer 26 PUBLIC Analyzing and Diagnosing Errors 3.3 View Database Procedures in the SAP HANA Database Explorer
Use the SAP HANA database explorer to view and test a database procedure.
Prerequisites
● You have access to a running SAP HANA system that includes a database procedure.
Procedure
Find your procedure in your catalog browser, and then choose one of the following options:
Option Action
View information about the procedure's parameters Click the procedure to open.
View the CREATE statement associated with the proce Open the procedure, and then click the CREATE Statement dure tab.
Generate a CALL statement for the procedure Open the procedure, and then click Generate CALL Statement.
Open the procedure to debug it (SAP Web IDE only) Right-click the procedure, and then choose Open for debugging.
Related Information
Create a Simple "Tiny-World" Application
3.3.1 Debug Procedures in the SAP HANA Database Explorer
Debug your stored procedures by using the SQL debugger in the SAP HANA database explorer.
Prerequisites
You must have the DEBUG object privilege granted to the schema or the procedures, that you want to debug.
To allow a user to debug a procedure in another user's session, the secondary user must be granted the ATTACH DEBUGGER privilege. For example, user A can grant the ATTACH DEBUGGER privilege (using the
SAP HANA Database Explorer Analyzing and Diagnosing Errors PUBLIC 27 GRANT statement) to user B to allow user B to debug a procedure in user A’s session. User B also needs the DEBUG privilege on the procedure.
Context
In the SAP Web IDE, use the development perspective to create stored procedures in .hdbprocedure modules and build them into HDI containers. Switch to the database explorer to test and debug the built procedures. To make corrections to the stored procedures, return to the development perspective.
Using the SQL debugger with user-provided services or application-managed service instances is not supported.
Note
If you are debugging a procedure and subsequently make changes to the procedure, then you must restart the debugging session by detaching and re-attaching the debugger. Each debug session works with a snapshot of the procedure(s) and any subsequent changes to procedures are not visible in active debug sessions.
Procedure
1. Choose one of the following options to open the procedure for debugging:
Option Action
From the development perspective: 1. Open the stored procedure (the .hdbprocedure file.) 2. Right-click in the editor and choose Open Runtime Object. The database explorer opens, the HDI container ap pears in the catalog browser, and the metadata viewer for the procedure opens. 3. Right-click the procedure in the catalog browser item list and click Open for debugging.
From the database explorer: 1. Connect to the database. 2. Locate the stored procedure in the database browser, and then right-click and click Open for debugging.
The procedure opens in a code editor, the debugger opens on the right sidebar and connects to the database, and a debugger session starts.
2. Set breakpoints in the code of your stored procedure by clicking a line number. 3. Call the procedure by right-clicking the procedure in the catalog browser item list and clicking Generate CALL statement. a. In the code, enter values for any input parameters. b. Choose Run () from the global toolbar.
SAP HANA Database Explorer 28 PUBLIC Analyzing and Diagnosing Errors The SQL console opens and it contains the CALL statement for your procedure.
The debugger stops at the first breakpoint and the session is suspended until you resume the debugging. 4. Choose (Resume module execution (F8)) or (Step over next function call (F10)) to step through the code execution.
Next Steps
Once you are finished debugging, click Detach debugger from running application () to stop the debugging session.
3.4 SAP HANA Database Explorer Debugger Tutorials
Use the database explorer debugger to debug stored procedures and functions.
Use the tutorials in this section to help you understand the following tasks you can perform with the database explorer debugger:
● Attaching and detaching the debugger from your database ● Using breakpoints to debug procedures and functions ● Working with debugger variables and expressions ● Using the step over feature to debug your code step by step ● Working with watchpoints
Tutorial Requirements
Execute the following statements (using the same line numbering as below) to create the function func_add, and the procedure dp2, which are used extensively in the debugger tutorials:
CREATE FUNCTION func_add(x DOUBLE, y DOUBLE)
RETURNS result_add DOUBLE LANGUAGE SQLSCRIPT READS SQL DATA AS BEGIN result_add :=x + y;
END;
CREATE PROCEDURE "dp2" ()
LANGUAGE SQLSCRIPT SQL SECURITY INVOKER
--DEFAULT SCHEMA
READS SQL DATA AS BEGIN DECLARE lt1 TABLE(a INT); DECLARE category VARCHAR(20) ARRAY; DECLARE I INT:= 0; lt1.a[1] = 3; lt1.a[2] = 4;
SAP HANA Database Explorer Analyzing and Diagnosing Errors PUBLIC 29 lt1.a[3] = 2; category [1]:= 'CategoryA'; category [2]:= 'CategoryB'; category [3]:= 'CategoryC'; i=FUNC_ADD(2,4);
END;
3.4.1 Tutorial: Connecting the Debugger
Attach the database explorer debugger to your database.
Context
Start an active debugging session for a specific database and specific types of connections.
Procedure
1. Click the Debugger icon () on the right-hand tool bar to open the debugger. 2. Click the Attach debugger icon () and click the database you want to attach the debugger to. 3. Click OK. 4. In the Debugger Attach Options dialog, choose one of the following options for how the debugger is attached:
SQL console connections Debug executions of a procedure from a SQL console
Connections with the Debug connections that use the specified debug token. Click Choose a following debug token Debug Token... opens a dialog that shows current tokens in use by the current database.
Connections with the Debug connections with the given connection IDs are debugged. Click following HANA Choose a Debug Token... opens a dialog that shows connection IDs for connection IDs (comma- connections to the HANA database. separated):
Connections with the Debug connections with the specified HANA database user name and, following attributes optionally, the specified application user name. Use the Application user name option primarily for ABAP applications, as ABAP connections use the same HANA database user name, but a different application user name.
Results
A message appears on the top right corner of the screen indicating that the debugger has successfully connected and the Active Session dropdown menu shows the name of the connected database.
SAP HANA Database Explorer 30 PUBLIC Analyzing and Diagnosing Errors 3.4.2 Tutorial: Debugging a Procedure by Setting Breakpoints
Create a sample procedure and then set breakpoints where you want the debugging to pause during the execution of your code.
Prerequisites
You must have created the function func_add, and the procedure dp2, as specified in the SAP HANA Database Explorer Debugger Tutorials topic.
Context
To debug a procedure, HANA must first compile it. Breakpoints that are set before the procedure is compiled do not have a checkmark. Once the procedure is compiled, valid breakpoints show checkmarks. Setting a breakpoint after procedure compilation automatically moves the breakpoint to the next valid line, if it is not currently on a valid line.
Procedure
1. Right-click the dp2 file and click Open for Debugging. 2. Create a breakpoint on a specific line by clicking next to the line number.
A blue background appears at the line number, along with a checkmark. The checkmark indicates that the breakpoint has been validated by HANA as a valid line number for the breakpoint to exist on. 3. Right-click on dp2 again and click Generate CALL Statement. 4. Click Run to execute the procedure.
The procedure starts to run, but stops at the breakpoint, with a message in the top right corner of the screen indicating that the procedure has been suspended. The Console section of the debugger displays the message, Stopped at breakpoint. 5. To resume the execution of the procedure, click Resume (), or press F8, in the debugger window.
Results
The procedure has successfully executed, pausing at the set breakpoints.
SAP HANA Database Explorer Analyzing and Diagnosing Errors PUBLIC 31 Related Information
SAP HANA Database Explorer Debugger Tutorials [page 29]
3.4.3 Tutorial: Debugging a Function by Setting Breakpoints
Create a sample function and then set breakpoints where you want the debugging to pause during the execution of your code.
Prerequisites
You must have created the function func_add, and the procedure dp2, as specified in the SAP HANA Database Explorer Debugger Tutorials topic.
Context
You cannot set breakpoints and debug a function directly. Instead, the function must be called through a procedure or a table function.
Procedure
1. Right-click the func_add function and click Open for debugging. 2. Click on a line in the function to create a breakpoint.
A dialog pops up that says that debugging scalar UDFs is only supported if the UDF is assigned to a variable within a procedure or a table function that also has a breakpoint set. 3. Click OK in the dialog box and call the procedure, dp2, which calls func_add, by right-clicking the procedure and clicking Generate CALL Statement Run .
Results
When dp2 is called, you can see that func_add breaks on the set breakpoints, since dp2 calls the function at line 17.
SAP HANA Database Explorer 32 PUBLIC Analyzing and Diagnosing Errors Related Information
SAP HANA Database Explorer Debugger Tutorials [page 29]
3.4.4 Tutorial: Debugging an Anonymous Block
Create a function that contains an anonymous block and then set breakpoints where you want the debugging to pause during the execution of your code.
Prerequisites
To set breakpoints in an anonymous block, set the Stop at execution start option in the Debugger Attach Options dialog when you attach the debugger to your database.
Context
You cannot set breakpoints and debug a function directly. Instead, the function must be called through a procedure or a table function.
When debugging anonymous blocks, breakpoints and watchpoints are not persisted between executions.
Procedure
Call the procedure dp2, which contains an anonymous block, by right-clicking the dp2 procedure in the Procedures item list and clicking Generate CALL Statement.
Results
When you execute the SQL, a second, read-only editor tab opens and execution is paused at the start of the SQL. You can step through the code, set breakpoints, and debug just as you can when debugging procedures and functions.
SAP HANA Database Explorer Analyzing and Diagnosing Errors PUBLIC 33 3.4.5 Tutorial: Debugging a SQLScript Library
Debug a SQLScript Library in the SAP HANA database explorer.
Prerequisites
You must be running a HANA database of version 2.0 SPS 04 or later.
To set a watchpoint in the SQLScript library, you must first set the SQLScript library member in the Add Watchpoint dialog.
Procedure
Right-click the SQL library that you want to debug and click Open for Debugging.
Results
The library opens in the debugging editor where you can set breakpoints.
3.4.6 Tutorial: Working With Expressions in the Debugger
Select one or more expressions to evaluate during the debugging session.
Prerequisites
You must have created the function func_add, and the procedure dp2, as specified in the SAP HANA Database Explorer Debugger Tutorials topic.
Context
The Expressions tab in the debugger allows you to watch expressions as executions are paused. As you step through the code, the debuggers watches the expression and returns any results.
SAP HANA Database Explorer 34 PUBLIC Analyzing and Diagnosing Errors Procedure
1. Right-click the dp2 file and click Open for Debugging. 2. Click the Expressions tab and then click Add Watch Expression (). 3. Choose SQLScript in the Module type drop-down menu. 4. In the Expression Text field, type the expression i + 5.
The debugger watches the expression during the debug session and will return all values for i plus 5. 5. Click Add. 6. (Optional) To edit an expression, select the expression and click Edit (). 7. Set breakpoints on lines 13 and 18 in the dp2 procedure and run the procedure by right-clicking dp2 and clicking Generate CALL Statement Run .
The procedure stops at line 13, and in the Expressions tab, the value of i + 5 is displayed as 5, since i was declared as 0 on line 9. 8. Click Resume () to continue execute the procedure.
The procedure now stops at line 18, and in the Expressions tab, the value of i + 5 has changed from 5 to 11. This is because on line 17, the value of i became 6, when the code i=FUNC_ADD(2,4); was executed.
Results
You have run a debugging session on procedure dp2, where the expression i + 5 was watched and returned varying results, depending on the breakpoint set.
3.4.7 Tutorial: Working with Variables in the Debugger
View variable values within the procedure or function that you are debugging.
Prerequisites
You must have created the procedure dp2, as specified in the SAP HANA Database Explorer Debugger Tutorials topic.
Context
The Variables tab in the debugger allows you to view variables and their definitions as executions are paused during the debug session.
SAP HANA Database Explorer Analyzing and Diagnosing Errors PUBLIC 35 Procedure
1. Right-click the dp2 file and click Open for Debugging. 2. Set a breakpoint at line 14.
3. Right-click the procedure and click Generate CALL Statement Run to run the procedure.
The procedure pauses on line 14. 4. Click Variables and click Local to view the different variables in your procedure along with their values. 5. Click the LT1: table[3] variable and then click Display Content () to view the contents of the selected variable. 6. If the variable can be changed, then the Edit icon () is enabled and you can click the icon to change value.
The following global and local variable types can be changed:
○ BINARY, VARBINARY ○ BOOLEAN ○ STRING ○ CHAR, NCHAR, VARCHAR, NVARCHAR, VARCHAR3, VARCHAR2 ○ DATE, TIME, TIMESTAMP, DAYDATE, SECONDTIME, LONGDATE, SECONDDATE ○ INTEGER, INT, TINYINT, SMALLINT, BIGINT ○ DECIMAL, SMALLDECIMAL ○ REAL, DOUBLE, FLOAT
Results
You have run a debugging session on procedure dp2, where you examined the definition for the variable LT1: table[3], when the procedure paused execution at line 14.
3.4.8 Tutorial: Working With Watchpoints in the Debugger
Setting a watchpoint in the debugger to pause code execution when a specified condition is encountered.
Prerequisites
You must have created the function func_add, and the procedure dp2, as specified in the SAP HANA Database Explorer Debugger Tutorials topic.
SAP HANA Database Explorer 36 PUBLIC Analyzing and Diagnosing Errors Context
A watchpoint acts like a breakpoint, but rather than specifying a line at which to pause code execution, you specify a condition at which to pause code execution. For example, you can pause code execution when the a specified expression is true or when the result of a specified variable changes values.
Procedure
1. Right-click the dp2 file and click Open for Debugging. 2. Click Add Watchpoint () to add a watchpoint. 3. In the Add Watchpoint dialog, choose the condition When expression is true from the Watchpoint condition dropdown menu. 4. Specify i=6 in the Expression after field.
Notice that the watchpoint is added to the Breakpoints view.
5. Run the dp2 procedure by clicking Generate CALL Statement Run .
The procedure stops at line 18 with a message in the Console box stating that the procedure execution stopped due to the specified watchpoint. 6. (Optional) Edit the expression in the watchpoint. a. Click the watchpoint and click Edit Watchpoint (). b. Change the value in Expression after to i<6. 7. Re-run procedure dp2.
The code now pauses execution at line 11, since that is the first instance where the value of the variable i is less than 6.
Results
You have successfully created and edited a watchpoint in the debugger.
3.4.9 Tutorial: Quitting the Debugging Session
Explicitly quit your debugging session by detaching the debugger from your application, or by setting a debugger timeout limit.
Context
SAP HANA Database Explorer Analyzing and Diagnosing Errors PUBLIC 37 Procedure
1. Quit your debugging session. a. Click Detach Debugger from Running Application ()
A message appears on the top right of the screen, indicating that the debugger is detatched. 2. Set the timeout limit for the debugger. a. Click Preferences (). b. Click the SQLScript Debugger option. c. Enter the number of minutes you want to set the debugger session timeout limit to and click Save.
Results
You have quit your current debug session and set a timeout (in minutes) preference for all debugging sessions.
SAP HANA Database Explorer 38 PUBLIC Analyzing and Diagnosing Errors 4 Querying the Database
Execute queries on your database using the SQL console. These queries can be run as background activities.
The database explorer SQL console includes the following functionality:
● Executes batches of statements, separated by semicolons. ● Includes a code-completion feature, as well as a code-formatting feature. Right-click within the SQL console to run these features. ● Includes the SQL analyzer to help you analyze the performance of your queries.
To view keyboard shortcuts, right-click anywhere in the SQL console and then click Keyboard Shortcuts from the context menu.
SQL Console Preferences
Set preferences for your SQL consoles by navigating to Global Preferences SQL Console .
You can set the following preferences:
● The theme and font size for your console editor ● The behavior of results sets, such as: ○ LOB byte limit ○ Display format of NULL values ○ The maximum numbers of rows to display ○ The maximum number of open results ○ Whether to search for a custom command separator when parsing ○ Whether to continue, stop, or provide a prompt when a SQL error is encountered ○ Whether SQL statements should be prepared before executing ○ Whether potential SQL errors should be indicated ○ Whether or not text should be parsed into multiple statements before executing ○ Whether to close results before executing another SQL statement ● Auto-saving the contents of your console to your local storage for the duration of your session (if your browser supports saving content) ● Auto-committing new SQL console contents (by default DML contents are auto-committed)
Statement Syntax Help
Use the SQL console side panel to access syntax for SQL statements and to view metadata SQL objects. You can view the following information:
SAP HANA Database Explorer Querying the Database PUBLIC 39 Statement/Syntax View the syntax of the statement you are currently editing and use the statement link to access full reference documentation for the statement.
Tables and Views View information on the tables or views being referenced in the current console and use the title link to open the table or view definition.
Procedures and View information on procedures or functions being referenced in the current console Functions and use the link to open the procedure or function definition.
SQL Functions View information on built-in functions and use the link to access full reference documentation for the function.
Statement History
View the 50 most recently executed SQL statements in the History tab, located beside the Results and Messages. Double-click a statement in the History tab to load it into the text editor. Closing the SQL console erases the current statement history.
4.1 Execute SQL Statements
Execute SQL statements and analyze their results by using the SQL console that is included with the SAP HANA database explorer.
Prerequisites
You must have the required privileges in the SAP HANA database to execute your SQL statements.
Context
Be default, DML contents are autocommited and syntax errors are indicated.
To view keyboard shortcuts, right-click anywhere in the SQL console and then click Keyboard Shortcuts from the context menu.
Procedure
1. Open an SQL console from the database explorer by right-clicking your database and clicking Open SQL Console.
SAP HANA Database Explorer 40 PUBLIC Querying the Database 2. Specify a SQL statement.
For example, the following statement returns users who have the EXPORT or IMPORT system privilege:
SELECT * FROM EFFECTIVE_PRIVILEGE_GRANTEES WHERE (OBJECT_TYPE = 'SYSTEMPRIVILEGE')
AND (PRIVILEGE = 'EXPORT' OR PRIVILEGE='IMPORT');
You can also import SQL directly into the console by clicking the Import File icon ( ) and choosing a local file. 3. Execute on or more statements by choosing one of the following options:
Option Action
Execute all statements Click the Run icon () from the global toolbar or press F8.
Execute individual statements Highlight the statement, and then click the Run icon () from the global toolbar or press F8.
Execute a SQL query on multiple databases Open a SQL console, create your query and then click Run Run on Multiple Databases . Click the data bases, groups, or resources where you want to run the query. The query runs as a background activity. Option ally, click Cancel all queries on SQL error, to stop subse quent queries from running on all databases if one of your queries encounters a SQL error. Click Run SQL.
Execute a query and open the SQL analyzer to view in Open the Run dropdown list from the global toolbar, and formation about the query's plan then choose Analyze SQL.
A new tab opens to display the query plan for your state ment in the SQL analyzer.
To save the plan, click Analyze SQL and Save Plan and specify a filename for the plan. You can also specify whether to run the analysis as a background activity.
Execute the content of the current line Open the Run dropdown list from the global toolbar, and then choose Run Line.
Prompt for the values of parameters before executing Open the Run dropdown list from the global toolbar, and the statement then choose Prepare Statement.
Results
The Result pane appears with the results. Multiple Result tabs appear when there is more than one result set. By default, only the first 1000 rows in a result set are retrieved.
SAP HANA Database Explorer Querying the Database PUBLIC 41 Related Information
Introduction to SQL SAP HANA SQL Reference About SAP HANA SQLScript Analyzing Statement Performance [page 70] Setting User Preferences Run a Query as a Background Activity [page 43] Use the Statement Library to Administer Your Database [page 44]
4.2 Execute Parameterized Statements
Create and execute parameterized statements in the SQL console.
Context
Parameterized statements provide more flexibility to your application when the name of an object, or the value for a statement option, is not known until execution time.
Procedure
1. Enter your statement in the SQL console and click Run.
For example:
SELECT * FROM SYS.TABLES WHERE SCHEMA_NAME=?;
A Parameters tab appears below the code. 2. Provide the parameter value by either entering it in the field provided or uploading it from a CSV file. 3. Click the Run button on the Parameters tab to execute the statement with the given parameter values. 4. (Optional) To prepare the parameterized statement again, click the Run button on the SQL console. Any parameter values that were entered in the Parameters tab are discarded.
Results
The statement executes with the given parameters and the results are returned on the Result tab.
SAP HANA Database Explorer 42 PUBLIC Querying the Database 4.3 Run a Query as a Background Activity
Set a query to run as a background activity, which continues running even if the browser window is closed.
Context
Run a query as a background activity when the query is expected to run for a long time, for example, a query that exports a schema or merges trace files.
Running a query as a background activity stores the query status and results, which can be retrieved at a later time, and then disconnects you from the SQL console where the query was run from. The disconnected SQL console remains open and can be reconnected to the same, or a different, database.
Background activities have the following limitations:
● Once the background activity has started running, the connection from the SQL console that started the query is used to run the query. Once the background activity completes, the connection is closed. You cannot reconnect to a connect that has been used by a background activity. ● Result sets are stored compressed and encrypted. You can store a maximum of 100 MB of background activity results. If this limit is exceeded, background activity results are no longer stored and you cannot create new background activities until you free up space by deleting completed background activities. ● The first 256 characters of the query are stored unencrypted as part of the query's description.
Procedure
1. Choose one of the following options to run your query as a background activity:
Option Action
Execute a long-running SQL query as a background ac Open a SQL console, create your query and then click tivity Run Run as Background Activity .
Execute a SQL query on multiple databases Open a SQL console, create your query and then click Run Run on Multiple Databases . Click the data bases, groups, or resources where you want to run the query. Click Run SQL.
The query runs as a background activity and you are disconnected from the SQL console where the query was run.
2. (Optional) Choose one of the following options:
Option Action
View the status of your background activities Click in the bottom, right-hand corner of your screen to open the Background Activities Monitor.
SAP HANA Database Explorer Querying the Database PUBLIC 43 Option Action
View the results of one or more background activities In the Background Activities Monitor, double-click a single query to view its results in a new SQL console, or select more than one query and click Open Details for Selected Row(s) ( ). The results for each background activity open in a separate console.
Cancel a background activity In the Background Activities Monitor, select the back ground activity you want to cancel and click Cancel Selected Row(s) ( ).
Delete a background activity from the Background In the Background Activities Monitor, select the back Activities Monitor ground activity you want to delete from the monitor and click Delete Selected Row(s) ( ).
Related Information
Execute SQL Statements [page 40] Use the Statement Library to Administer Your Database [page 44]
4.4 Use the Statement Library to Administer Your Database
The statement library in the SAP HANA database explorer contains default system statements and can also be used to store user-defined statements.
Prerequisites
The maximum size allowed per user for all stored statements is 10 MB, uncompressed.
Only user-defined statements can be accessed by HDI containers.
You cannot use forward slashes (/) in a statement name. Otherwise, there are no character restrictions.
Context
Default system statements include all statements available in the M_SYSTEM_INFORMATION_STATEMENTS system view and all statements included in SAP Note 1969700.
You can edit statement contents and descriptions in the SQL console and then save them back to the statement library as a new statement, or by replacing the old version.
SAP HANA Database Explorer 44 PUBLIC Querying the Database Create your own SQL statements for administration purposes directly in the SQL console and add them to the statement library. Alternatively, you can import statements saved as ZIP files, .sql files, or .txt files from your local computer or network file server.
The content of statements stored in the statement library is encrypted, except for the statement description; do not include sensitive information in your statement description.
The statement library is user-specific, therefore all stored statements are available for every database associated with a specific user.
Action Description
Create a statement and add it to the statement library. 1. In the catalog browser, right-click your database and click Open SQL Console. 2. Enter your SQL statement. Including a header is optional. However, a description for your SQL statement will not show up in the statement library unless you create one in your statement header. The format for your statement description is as follows:
/*
[DESCRIPTION] --Sample description
*/
The statement description in the statement library shows the first line of the content after the [DESCRIPTION] section header. 3. Click to add the statement to the statement library. You can change the statement name and see how the name and statement description will show up in the library.
Import a statement to your statement library 1. To import a SQL statement or set of statements to the statement library, right-click your database and click Show Statement Library. 2. Click Import.
A file browser opens that allows you to import an individual statement in a .sql, .txt, or XML file, or a set of statements in a ZIP file.
ZIP file hierarchies are flattened in the statement library.
Export a file from the statement library Note
You can only export, delete, or rename statements with the type USER.
1. To export a USER-type statement from the statement library, select the statement and click Export, or right-click a statement and click Export.
Individual statements are exported as .sql files.
SAP HANA Database Explorer Querying the Database PUBLIC 45 Action Description
Edit a statement in the library Edit a stored SQL statement by clicking its folder in the statement library and clicking .
The statement opens in the SQL console where you can edit the syntax and description and add it back into the statement library under the same name or a different name.
Related Information
SAP Note 1969700 M_SYSTEM_INFORMATION_STATEMENTS System View
4.5 Work With Graph Workspaces in SAP HANA Database Explorer
View and work with graph workspaces in the SAP HANA database explorer.
Prerequisites
You must have an existing graph workspace in your database.
Context
Running an algorithm expands 1000 vertices. Applying a filter returns a maximum of 1000 records.
Configure the number of vertices that expand when you double-click to a maximum of 50.
For more information about graph workspaces, see the SAP HANA Graph Reference guide.
Procedure
View graph workspaces in the database explorer. a. Click the Graph Workspaces object in the catalog browser.
SAP HANA Database Explorer 46 PUBLIC Querying the Database A list of all available graph workspaces for your database appears both in the graph workspaces editor and in the catalog browser item list.
Option Action
View schema information for a graph workspace Right-click a graph workspace and click Open to view infor mation about the graph workspace, such as the names of the edge and vertex tables, the schema the graph workspace belongs to and its creation time.
View data in a graph workspace Right-click a graph workspace and click View Graph. The graph workspace opens in the graph visualizer and allows you to perform the following actions:
Add Fil Narrow your result set by setting conditions for ter () both your vertices and edges. To apply a filter, se lect a column, operator, and value. Multiple filters can be added.
Apply Apply one of the following algorithms: Algo rithm Neighbor Returns neighboring nodes of a () hood specific vertex. Specify a start ver tex, direction, and depth.
Shortest Find the shortest path between Path the source and target vertices.
Strongly Shows a group of nodes where ev Connected ery node is reachable from every other node to form a strongly con nected component. Nodes belong ing to the same component are shown in the same colour.
Cypher Write a cypher query using edge and vertex variables to define a pattern of subgraphs. The result contains subgraphs that match the pattern defined in the query.
Set Change the labels of your vertices and edges. tings Highlight vertices containing a specific value with () the same color. Use the Preferences option to set the vertex expansion limit when you double-click, or set the forced layout threshold time.
Proper The drop-down properties pane on the left side of ties the screen, shows all attributes associated with the selected vertex and edge and the number of incoming and outgoing edges. It also contains quick links for algorithms.
Reset your graph at anytime by clicking
SAP HANA Database Explorer Querying the Database PUBLIC 47 5 Analyzing Performance
Improve the performance of query execution by analyzing SQL statements, and procedures and functions written in SQLScript.
5.1 Configure Tracing in the SAP HANA Database Explorer
Various types of tracing are available in the SAP HANA database explorer for obtaining detailed information about your database system operations.
Prerequisites
To configure tracing, you must have the TRACE ADMIN system privilege.
You must be connected to an SAP HANA database. You cannot configure tracing for HDI containers or cockpit resources.
Procedure
1. Right-click your database and click Trace Configuration. 2. Click Edit on the type of tracing that you want to configure. 3. On the Trace Configuration editor, configure your trace settings and click OK.
Results
You have configured your tracing type and can now view and download tracing results from either your Database Diagnostic Files folder or your Host Diagnostic Files folder.
Related Information
Traces
SAP HANA Database Explorer 48 PUBLIC Analyzing Performance 5.2 View Diagnostic Files in the SAP HANA Database Explorer
Diagnose and analyze errors in an SAP HANA database by viewing the relevant diagnostic files in the SAP HANA database explorer.
Context
In the catalog browser, diagnostic files for online databases are grouped by host and then by service. In a multi- host system, check each host folder to view all diagnostic files associated with a particular service.
Procedure
Choose one of the following options:
Option Description
View diagnostic files Open the Database Diagnostic Files folder of your database, then right-click the diagnostic file that for a database that is you want to examine and click Show Files to open the file in an editor. If the trace file is binary, then online and available it cannot be opened in the database explorer, but can be downloaded. The Database Diagnostic Files folder contains all diagnostic files that are available through the database's M_TRACEFILES system view.
View diagnostic files Open the Host Diagnostic Files folder of your cockpit database, then right-click the diagnostic file for a cockpit data that you want to examine and click Show Files to open the file in an editor. If the trace file is binary, base that is either then it cannot be opened in the database explorer, but can be downloaded. The Host Diagnostic online or offline Files folder contains all diagnostic files that have been configured for the SAP Host Agent.
For more information about configuring the SAP Host Agent, see the SAP Host Agent documenta tion.
The cockpit database must have valid SAP Control Credentials set in the cockpit. If the user has not set valid SAP Control Credentials, then an error is returned.
View diagnostic files Under the Database Diagnostic Files folder of your database, right-click the folder of the tenant da for tenant databases tabase that you want to view trace files for, and then click Show Files to open the file in an editor. in an MDC system Note
You must be connected to the system database as the SYSTEM user.
SAP HANA Database Explorer Analyzing Performance PUBLIC 49 Related Information
Collecting Diagnosis Information for SAP Support
5.2.1 Viewing the Trace File List
See all the trace files in your system.
Seeing traced files currently in your system is useful for SAP HANA database monitoring and analysis.
To view the trace file, open the SAP HANA database explorer. Right-click the desired host folder, and click Show Files.
The trace file list opens, showing all traced files currently in the system. You can also see their metadata such as the host, file name, size, and the time the file was modified.
To support monitoring and analysis, you can perform the following actions on the trace file list:
● Define the sorting order of the traced files ● Filter the results according to a desired parameter ● See the traced file’s contents by selecting its row from the table
Note
You cannot see the full contents of a traced file. It only loads partial content from the start or the end of a file.
● In the contents view, you can choose to show the start or the end of the traced file ● In the contents view, you can input lines up to 10MB in size.
5.2.2 View Diagnosis Files of an Unavailable Tenant Database
If a tenant database is unavailable, for example because it's stopped or experiencing major performance problems, the tenant database administrator can't access diagnosis files. In this case, you as the system administrator can access the diagnosis files of the tenant database from the system database using the SAP HANA database explorer.
Procedure
Open the Host Diagnostic Files folder of your cockpit database, then click the diagnostic file that you want to examine to open it in an editor. The Host Diagnostic Files folder contains all diagnostic files that have been configured for the SAP Host Agent.
SAP HANA Database Explorer 50 PUBLIC Analyzing Performance Note
You cannot open binary trace files (marked with a binary icon) in the database explorer. You can only download binary trace files.
For more information about configuring the SAP Host Agent, see the SAP Host Agent documentation.
The cockpit database must have valid SAP Control Credentials set in the cockpit. If the user has not set valid SAP Control Credentials, then an error is returned.
The diagnosis files of the system database are displayed.
Next Steps
If more detailed diagnosis information is required (for example for SAP Support), you can trigger the collection of a full system information dump for tenant databases. For more information, see Collecting Diagnosis Information for SAP Support in the SAP HANA Administration Guide.
Related Information
Add a Database to the SAP HANA Database Explorer [page 10] View Diagnostic Files in the SAP HANA Database Explorer [page 49] SAP Host Agent
5.3 Traces
SAP HANA provides various traces for obtaining detailed information about the actions of the database system for troubleshooting and error analysis.
The following is an overview of the main traces available in SAP HANA:
Configure or Run... To... Using...
Database trace Understand activity in the components of the SAP HANA database explorer SAP HANA database in general, or for a spe SAP HANA studio cific user or client operation
Note
Database tracing is always active. Informa tion about error situations is always re corded in alert trace files.
SAP HANA Database Explorer Analyzing Performance PUBLIC 51 Configure or Run... To... Using...
SQL trace Collect information about all SQL statements SAP HANA database explorer executed on the index server SAP HANA studio
Expensive statements Record information about individual SQL state SAP HANA cockpit ments whose execution time exceeded a con SAP HANA database explorer figured threshold SAP HANA studio
Plan trace Visualize the execution plans of SQL SELECT SQL analyzer statements for in-depth query performance SAP HANA PlanViz perspective of analysis the SAP HANA studio Note
The plan trace is part of the SAP HANA tools for query execution analysis: the Web-based SQL analyzer, which is inte grated into the SAP HANA cockpit and SAP Web IDE for SAP HANA, and the SAP HANA PlanViz perspective of the SAP HANA studio.
Deadlock Detection Create a waitgraph file that contains thread in SAP HANA database explorer (SQL formation about deadlocks. Statement)
Performance trace Record performance indicators of individual SAP HANA studio query processing steps in the database kernel for detailed performance analysis by SAP Sup port
Kernel profiler Generate a profiler trace for detailed perform SAP HANA database explorer ance analysis by SAP Support SAP HANA studio
Full system information dump Create a runtime dump if requested by SAP SAP HANA cockpit or SAP HANA support to understand the behavior of SAP studio HANA in a problem situation
SAP Web Dispatcher HTTP traces Analyze HTTP requests SAP HANA cockpit or SAP HANA studio
Related Information
Database Trace (Basic, User-Specific, and End-to-End) [page 53] SQL Trace [page 58] Performance Trace [page 62] Expensive Statements Trace [page 63] Kernel Profiler [page 66] Traces and Trace Configuration for Internal Web Dispatcher [page 68] Configure Tracing in the SAP HANA Database Explorer [page 48]
SAP HANA Database Explorer 52 PUBLIC Analyzing Performance 5.3.1 Database Trace (Basic, User-Specific, and End-to-End)
The database trace records information about activity in the components of the SAP HANA database. You can use this information to analyze performance and to diagnose and debug errors.
Database Trace Files
Each service of the SAP HANA database writes to its own trace file. The file names follow the default naming convention:
Example
indexserver_veadm009.34203.000.trc
Information recorded by the alert trace component of the database trace is written to a separate file to ensure that critical information is easy to find. The file names follow the default naming convention:
Note
The trace files generated for the Web Dispatcher service are different. For more information, see Trace Configuration for Internal Web Dispatcher.
You access database trace files with other diagnosis files.
Basic Database Trace Configuration
Database tracing is always active. This means that information about error situations is always recorded. However, for more detailed analysis of a specific problem or component, you may need to configure a certain trace component to a trace level higher than the default value. For example, the backup trace component records information about backup operations, the authorization component records information about authorization operations, and so on.
Tip
For more information about which trace component to use for which situation, see SAP Note 2380176.
Changing the trace level of a trace component
If a trace component is available in all services, the trace level can be configured for all services at once. It is also possible to configure the trace level of a component individually for a specific service. The trace level of a component configured at service level overrides the trace level configured for all services. Some components are only available in a particular service and cannot therefore be changed globally.
SAP HANA Database Explorer Analyzing Performance PUBLIC 53 Example
You change the trace level of the memory component to ERROR for all services and for the indexserver service, you change it to WARNING. This means that the memory component of the indexserver service will trace up to level WARNING and the memory component of all other services will trace to the level ERROR.
You can configure the trace levels of database trace components in the SAP HANA database explorer or the SAP HANA studio. Alternatively, you can modify the parameters in the trace section of the global.ini configuration file (for all services) or service-specific files such as indexserver.ini. The individual parameters correspond to trace components and the parameter value is the trace level.
Example
Use the following statement to set the trace level of the authentication component to DEBUG:
ALTER SYSTEM ALTER CONFIGURATION ('indexserver.ini', 'SYSTEM') SET ('trace', 'authentication') = 'DEBUG' WITH RECONFIGURE
Note
In the SAP HANA database explorer and SAP HANA studio, a trace level that has been inherited from the global or ALL SERVICES configuration (either the default or system configuration) is shown in brackets.
What trace levels are possible?
The higher the trace level, the more detailed the information recorded by the trace. The following trace levels exist:
● NONE (0) ● FATAL (1) ● ERROR (2) ● WARNING (3) ● INFO (4) ● DEBUG (5)
Note
Even if you select trace level NONE, information about error situations is still recorded.
Alert Trace Component
The alert trace component is used to ensure that critical information is easy to find by duplicating high- priority trace messages to separate alert trace files. By default, trace messages with trace level ERROR and higher are written to the alert trace file.
Example
If the alert component is set to WARNING, the alert trace contains messages created with trace levels WARNING, FATAL and ERROR.
SAP HANA Database Explorer 54 PUBLIC Analyzing Performance User-Specific and End-to-End Database Traces
User-specific and end-to-end traces extend the configured database trace by allowing you to change the trace level of components in the context of a particular user or end-to-end analysis. The trace levels configured for components in these contexts override those configured in the database trace.
Example
In the database trace, you changed the trace level of the memory component to ERROR for all services, and for the indexserver service you changed it to WARNING. Now, you create a user-specific trace for User1 and increase the trace level for all services to WARNING. For the indexserver service, you increase it to DEBUG. This results in the following tracing behavior for the memory component:
● For all users except User1, all services except the indexserver will trace to ERROR ● For all users except User1, the indexserver will trace to WARNING ● For User1, all services except the indexserver will trace to WARNING ● For User1, the indexserver will trace to DEBUG
If you are connected to a database of version HANA 2.0 SPS 03, then you can use the Statement Hash option when configuring user-specific tracing in the SAP HANA database explorer. This option allows you to filter your tracing according to specific SQL statements.
To run tracing on a specific SQL statement, you must first find the unique identifier (statement hash) for that statement and enter it in the Statement Hash field when configuring your user-specific trace session.
For example, if you want to see trace information when running the statement SELECT * FROM DUMMY;, then execute the following statements to find the its statement hash:
SELECT * FROM DUMMY;
SELECT statement_string, statement_hash FROM m_sql_plan_cache WHERE statement_string = 'SELECT * FROM DUMMY;';
Enter the result of the second statement into the Statement Hash field of the User-Specific Trace configuration dialog to include tracing for the SELECT * FROM DUMMY; statement in your user-specific trace.
End-to-End Traces
End-to-end traces are triggered by applications outside of the SAP HANA database. The default trace levels for the SAP HANA database components are normally sufficient and do not need to be changed. For more information about end-to-end analysis in your landscape, see SAP Library for Solution Manager on SAP Help Portal.
Related Information
Traces and Trace Configuration for Internal Web Dispatcher [page 68] End-to-End Analysis Overview SAP Note 2380176
SAP HANA Database Explorer Analyzing Performance PUBLIC 55 5.3.1.1 Database Trace Configuration in Tenant Databases
Tenant databases inherit the database trace level configured in the system database unless you change the trace level in the tenant database.
The trace level of trace components in a tenant database is inherited from the system database as the default value. If you want to configure a different trace level for a particular component in the tenant database, either globally for all services or for a specific service, you can do so by changing the trace level of the relevant component.
Note
In the SAP HANA studio, the trace level of a component will also be displayed as the system trace level, and you cannot change the system trace level. This is because from the perspective of the tenant database, the database and the system are effectively the same. The true system trace level (that is, the value configured in the system database) appears as the default trace level for the tenant database.
Note
A trace level that has been inherited from the ALL SERVICES configuration (either the default or database configuration) is shown in brackets.
Example
In the following example, you can see that the default trace level for the component assign inherited from the system database is WARNING. The trace level was changed to INFO for all services in this database. The indexserver service therefore inherits this trace level. All the other components keep the default configuration.
Database Trace Configuration in a Tenant Database (Studio View)
SAP HANA Database Explorer 56 PUBLIC Analyzing Performance 5.3.1.2 Configure Database Trace File Rotation
Trace file rotation prevents trace files from growing indefinitely by limiting the size and number of trace files. You can configure trace file rotation globally for all services in the database and for individual services.
Prerequisites
You have the system privilege INIFILE ADMIN.
Context
You configure trace file rotation in the global.ini configuration file (all services) or the service-specific file (for example, indexserver.ini).
Procedure
Depending on whether you are configuring trace file rotation for all system services or for an individual service, proceed as follows:
Option Description
All serv In the trace section of the global.ini file, configure the following parameters: ices ○ maxfiles by specifying the maximum number of trace files that may exist ○ maxfilesize by specifying in bytes the maximum size an individual trace file may reach
Note The default configuration for trace file rotation in the global.ini file is maxfiles=10 and maxfilesize=10000000.
Individual In the trace section of the global.ini file, configure the following parameters. If there is no trace section, service add one. ○ maxfiles by specifying the maximum number of trace files that may exist ○ maxfilesize by specifying in bytes the maximum size an individual trace file may reach in bytes
Note If these two parameters do not exist in the trace section or if you created a new trace section, create them.
SAP HANA Database Explorer Analyzing Performance PUBLIC 57 Results
When a trace file reaches the specified maximum file size, it is closed, and a new file created. When the specified maximum number of files is reached, the next time a new file is created, the first file is deleted, and so on.
Note
The system checks the size and number of diagnosis files regularly. The threshold values for these checks (check 50 and 51) should be in line with the configured trace file rotation.
5.3.2 SQL Trace
The SQL trace collects information about all SQL statements executed on the index server (tenant database) or name sever (system database) and saves it in a trace file for further analysis. The SQL trace is inactive by default.
Information collected by the SQL trace includes overall execution time of each statement, the number of records affected, potential errors (for example, unique constraint violations) that were reported, the database connection being used, and so on. The SQL trace is a good starting point for understanding executed statements and their potential effect on the overall application and system performance, as well as for identifying potential performance bottlenecks at statement level.
SQL Trace Files
SQL trace information is saved as an executable python program (by default sqltrace_<...>.py), which can be used to replay the traced database operations. You can also use the SQL Trace Analyzer tool to automate the analysis of the file.
Enabling and Configuring the SQL Trace
You can enable and configure the SQL trace in the SAP HANA database explorer or SAP HANA studio. Alternatively, you can modify the parameters in thesqltrace section of the indexserver.ini (tenant database) or nameserver.ini (system database).
Example
Use the following statement to enable the SQL trace:
ALTER SYSTEM ALTER CONFIGURATION ('indexserver.ini', 'SYSTEM') SET ('sqltrace', 'trace') = 'on' WITH RECONFIGURE
SAP HANA Database Explorer 58 PUBLIC Analyzing Performance Recommendation
Do not leave the SQL trace enabled all the time as writing trace files consumes storage space on the disk and can impact database performance significantly.
Trace Levels
You can set the level for the SQL trace by changing the value of the configuration parameter [sqltrace] level in the indexserver.ini file (tenant database) or nameserver.ini file (system database). Trace information includes details such as executed timestamp, thread ID, connection ID, and statement ID.
Trace Level Description
NORMAL All statements that have finished successfully are traced.
ERROR All statements that returned errors are traced.
ERROR_ROLLBACK All statements that are rolled back are traced.
ALL All statements including status of normal, error, and rollback are traced.
ALL_WITH_RESULTS In addition to the trace generated with trace level ALL, the result returned by select state ments is also included in the trace file.
Note
An SQL trace that includes results can quickly become very large.
Caution
An SQL trace that includes results may expose security-relevant data, for example, query result sets.
Trace Details
You can configure trace detail information by setting the parameter [sqltrace] details. You can select one or more categories of information to include in the trace, for example: 'basic,resource_consumption'. Possible values are listed in the following table. Note that for resource consumption information (this is also included in the 'all' option) the following two parameters in the global.ini file [resource_tracking] section, must be set to 'on':
● enable_tracking ● memory_tracking
You may also wish to limit the maximum memory allocation per statement by setting a value for the [memorymanager] statement_memory_limit parameter in the global.ini file. Set this to 5, for example, to apply a limit of 5GB.
Trace Details Description
basic Connection information and statement information (default)
all Include all comments of connection and statement
user_variables User-defined variables in the session context
SAP HANA Database Explorer Analyzing Performance PUBLIC 59 Trace Details Description
statement Statement information such as executed timestamp, thread ID, connection ID, statement ID, statement hash and duration
session_variables System-defined variables in the session context
resource_consumption Statement resource consumption information such as local (+remote, if available) cpu- time and memory-size.
passport Decoded passport contents
connection Connection information such as session ID, transaction ID, client PID, client IP, user name, schema name, and session variable:value pairs
"empty" Trace without these comments
Additional Configuration Options
Option Configuration Parameter Default Description
Trace file name tracefile sqltrace_ User-specific name for the trace file $HOST_$ If you do not enter a user-specific file name, the file {PORT}_$ name is generated according to the following de {COUNT: fault pattern: 3}.py DB_
● DB_
User, applica user Empty string Filters to restrict traced statements to those of par tion, object, and ticular database or application users and applica statement fil- application_user tions, as well as to certain statement types and spe ters application cific objects (tables, views, procedures). All statements matching the filter criteria are re object corded and saved to the specified trace file. statement_type For user, application_user, and application the use of wildcards is supported (see following subsection Using Wildcards).
SAP HANA Database Explorer 60 PUBLIC Analyzing Performance Option Configuration Parameter Default Description
Flush limit flush_interval 16 During tracing, the messages of a connection are buffered. As soon as the flush limit number of mes sages is buffered (or if the connection is closed), those messages are written to the trace file.
When set to 0, every SQL trace statement is imme diately written to the trace file
Using Wildcards
If you apply filters for the user, application_user, and application parameters, the use of wildcards and exceptions is also supported. The asterisk wildcard character denotes any number of characters and the exclamation mark denotes an exclusion. For example: user=SM*,JONES,!GREEN,!BRO*
In this case all users starting with SM will be traced, JONES will be traced, user GREEN will not be traced and all users starting with BRO will not be traced. If terms in the string conflict with each other then the sequence in which the terms occur determines the result. In the following example user SMALL will be traced in spite of the exclusion; the exclusion is ignored because it occurs after the first wildcard. user=SM*,JONES,!SMALL,!BRO*
Trace File Rotation
The size and number of trace files are controlled by the following parameters.
Parameter Default Description
max_files 1 Sets the maximum number of trace files
filesize_limit 1610612736 (or 1.5 GB) Sets the maximum size of an individual trace file in bytes
Caution
If both the maximum number of files and the maximum file size are reached, SQL tracing stops. If this happens, you can increase the values of max_files and filesize_limit. See SAP Note 2629103.
SAP HANA SQL Trace Analyzer
SAP HANA SQL trace analyzer is a Python tool you can use to analyze the HANA SQL trace output. The tool gives you an overview of the top SQL statements, the tables accessed, statistical information on different statement types and on transactions executed.
For more information about the installation and usage of SAP HANA SQL trace analyzer, see SAP Knowledge Base Article 2412519 FAQ: SAP HANA SQL Trace Analyzer.
SAP HANA Database Explorer Analyzing Performance PUBLIC 61 Related Information
SAP Note 2412519 SAP Note 2629103
5.3.3 Performance Trace
The performance trace is a performance tracing tool built into the SAP HANA database. It records performance indicators for individual query processing steps in the database kernel. You may be requested by SAP Support to provide a performance trace.
Information collected includes the processing time required in a particular step, the data size read and written, network communication, and information specific to the operator or processing-step-specific (for example, number of records used as input and output). The performance trace can be enabled in multiple tenant databases at the same time to analyze cross-database queries.
Performance Trace Files
Performance trace results are saved to the trace files with file extension *.tpt or *.cpt, which you can access with other diagnosis files. To analyze these files, you need a tool capable of reading the output format (*.tpt and *.cpt). SAP Support has tools for evaluating performance traces.
Enabling and Configuring the Performance Trace
You can enable and configure the performance trace in the SAP HANA studio or using the ALTER SYSTEM * PERFTRACE SQL statements.
Example
To start the performance trace execute ALTER SYSTEM START PERFTRACE.
Configuration Options
Option Description
Trace file name The name of the file to which the trace data is automatically saved after the performance trace is stopped
User and application filters Filters to restrict the trace to a single specific database user, a single specific application user, and a single specific application
Trace execution plans You can trace execution plans in addition to the default trace data.
SAP HANA Database Explorer 62 PUBLIC Analyzing Performance Option Description
Function profiler The function profiler is a very fine-grained performance tracing tool based on source code instrumentation. It complements the performance trace by providing even more detailed in formation about the individual processing steps that are done in the database kernel.
Duration How long you want tracing to run
If a certain scenario is to be traced, ensure that you enter a value greater than the time it takes the scenario to run. If there is no specific scenario to trace but instead general system performance, then enter a reasonable value. After the specified duration, the trace stops au tomatically.
Additional filter options are available in extended mode to restrict the trace data further.
For more information about how to configure the performance trace using SQL, see the SAP HANA SQL and System Views Reference.
5.3.4 Expensive Statements Trace
Expensive statements are individual SQL statements whose execution time exceeds a configured threshold. The expensive statements trace records information about these statements for further analysis and is inactive by default.
If, in addition to activating the expensive statements trace, you enable per-statement memory tracking, the expensive statements trace will also show the peak memory size used to execute the expensive statements.
Expensive Statements Trace Information
If you have the TRACE ADMIN privilege, then you can view expensive statements trace information in the following ways:
● In the Expensive Statements app of the SAP HANA cockpit ● In the Statement Library in SAP HANA database explorer by searching for Expensive Statements Analysis. ● In the M_EXPENSIVE_STATEMENTS system view
Enabling and Configuring the Expensive Statements Trace
You can enable and activate the expensive statements trace in the SAP HANA cockpit or the SAP HANA database explorer. Alternatively, you can modify the parameters in the expensive_statement section of the global.ini configuration file.
SAP HANA Database Explorer Analyzing Performance PUBLIC 63 Configuration Options
Note
The following table shows the configuration parameters which are available; not all of these may be available in the SAP HANA cockpit or the SAP HANA database explorer.
Option Configuration Parameter Default Value Description
Trace status enable off Specifies the activation status of the trace.
Threshold CPU threshold_cpu_time -1 (disabled) Specifies the threshold CPU time of statement exe time cution in microseconds.
When set to 0, all SQL statements are traced.
Note
Resource tracking and CPU time tracking must also be enabled. You can do this by configuring the corresponding parameters in the resource_tracking section of the global.ini file.
Threshold threshold_memory -1 (disabled) Specifies the threshold memory usage of state memory ment execution in bytes.
When set to 0, all SQL statements are traced.
Note
Resource tracking and memory tracking must also be enabled. You can do this by configuring the corresponding parameters in the resource_tracking section of the global.ini file.
Threshold dura threshold _duration 1000000 ( mi Specifies the threshold execution time in microsec tion croseconds = 1 onds. second ) When set to 0, all SQL statements are traced. In the SAP HANA database explorer, you can set the threshold duration to be measured in seconds or milliseconds.
User, applica user Empty string Specifies filters to restrict traced statements to tion, and object those of a particular database, application user, ap filters application_user plication, or tables/views. For user, application application_user, and application the use of wildcards is supported (see following sub object section Using Wildcards).
SAP HANA Database Explorer 64 PUBLIC Analyzing Performance Option Configuration Parameter Default Value Description
Passport trace passport_tracelevel Empty string If you are activating the expensive statements trace level as part of an end-to-end trace scenario with the Process Monitoring Infrastructure (PMI), you can specify the passport trace level as an additional fil- ter.
This means that only requests that are marked with a passport of the specified level are traced.
Note
Process tracing is possible only for compo nents in the ABAP and Business Objects stacks.
Trace parame trace_parameter_values true In SQL statements, field values may be specified as ter values parameters (using a "?" in the syntax). If these pa rameter values are not required, then you can disa ble this setting to reduce the amount of data traced.
Trace flush in trace_flush_interval 10 Specifies the number of records after which a trace terval file is flushed.
Use in-memory use_in_memory_tracing true If in-memory tracing is active, then information is tracing cached in memory. Otherwise, the data is written directly to file.
In-memory in_memory_tracing_reco 30000 Specifies the maximum number of trace records tracing records rds (per service) stored in memory.
This setting only takes effect when in memory trac ing is active.
Using Wildcards
If you apply filters for the user, application_user, and application parameters, the use of wildcards and exceptions is also supported. The asterisk wildcard character denotes any number of characters and the exclamation mark denotes an exclusion. For example: user=SM*,JONES,!GREEN,!BRO*
In this case all users starting with SM will be traced, JONES will be traced, user GREEN will not be traced and all users starting with BRO will not be traced. If terms in the string conflict with each other then the sequence in which the terms occur determines the result. In the following example user SMALL will be traced in spite of the exclusion; the exclusion is ignored because it occurs after the first wildcard. user=SM*,JONES,!SMALL,!BRO*
Trace File Rotation
To prevent expensive statement trace information from growing indefinitely, you can limit the size and number of trace files using the following parameters in expensive_statement of global.ini.
SAP HANA Database Explorer Analyzing Performance PUBLIC 65 Parameter Default Description
maxfiles 10 Specifies the maximum number of trace files.
When the maximum number of trace files reached, the oldest trace file is de leted and a new one opened.
When set to 0, trace file rotation is disa bled.
maxfilesize 10000000 (or 9.5 megabytes) Specifies the maximum size of an indi vidual trace file in bytes.
When the maximum number of files is greater than 1 and the maximum file size is reached, a new trace file is opened.
When the maximum number of files is 1, the maximum file size is greater than zero, and the maximum file size is reached, the trace file is deleted and a new one opened.
Related Information
SAP Note 2180165
5.3.5 Kernel Profiler
The kernel profiler is a sampling profiler built into the SAP HANA database. It can be used to analyze performance issues with systems on which third-party software cannot be installed, or parts of the database that are not accessible by the performance trace. It is inactive by default.
The kernel profile collects, for example, information about frequent and/or expensive execution paths during query processing.
It is recommended that you start kernel profiler tracing immediately before you execute the statements you want to analyze and stop it immediately after they have finished. This avoids the unnecessary recording of irrelevant statements. It is also advisable as this kind of tracing can negatively impact performance.
SAP HANA Database Explorer 66 PUBLIC Analyzing Performance Enabling and Configuring the Kernel Profiler
You can enable and configure the kernel profiler in the SAP HANA Database Explorer (Trace Configuration) or you can manage the kernel profiler from the SQL command line using the ALTER SYSTEM command. In both cases RESOURCE ADMIN or TRACE ADMIN privileges are required.
Enabling Kernel Profiler using SQL
The kernel profiler statement supports basic functions such as start, stop, save and clear, but also a number of options such as to run the profile for a specific location, for a specific user or within certain memory limits.
The following examples illustrate the basic usage of the ALTER SYSTEM command:
ALTER SYSTEM START KERNEL PROFILER
ALTER SYSTEM SAVE KERNEL PROFILER
The SAVE keyword stops the profiler, saves the data (to the trace directory) and clears allocated memory. The following statement starts profiling at host:port ab1234:30003 and filters for the user specific trace (database trace) profile MYTRACEPROFILE
ALTER SYSTEM START KERNEL PROFILER AT 'ab1234:30003' TRACEPROFILE 'MYTRACEPROFILE';
Refer to the SAP HANA SQL Reference Guide for further options and details of these commands.
Configuration Options in Database Explorer
Option Description
Service(s) to profile The service(s) that you want to profile.
Sampling interval The amount of time the kernel profiler is to wait between call stack retrievals.
When you activate the kernel profiler, it retrieves the call stacks of relevant threads several times. It waits between each sample for the length of time specified here minus the time the previous retrieval took.
Memory limit Memory limit that will stop tracing.
The kernel profiler can potentially use a lot a memory. To prevent the SAP HANA database from running out of memory due to profiling, you can specify a memory limit that cannot be exceeded.
Optional filter The specific database user or application user you want to profile.
Kernel Profiler Traces
Profiling results are saved to two trace files. When started from SQL:
● kernel_profiler_cpu.dot ● kernel_profiler_wait.dot
SAP HANA Database Explorer Analyzing Performance PUBLIC 67 When started from Database Explorer:
● CPU_
To analyze these trace files you need a tool capable of reading the .dot output format, or you may be asked to send the files to SAP Support.
View M_KERNEL_PROFILER The view M_KERNEL_PROFILER displays the status of the profiler (started or stopped) and provides information about current kernel profilers. The view can also be accessed by users with RESOURCE ADMIN and/or TRACE ADMIN privileges.
5.3.6 Traces and Trace Configuration for Internal Web Dispatcher
Several traces and trace configuration options are available for the internal Web Dispatcher, which runs as a native SAP HANA service (webdispatcher).
Developer Trace
The developer trace is the main trace for the Web Dispatcher and contains technical information for troubleshooting problems.
The developer trace file is webdispatcher_
You can configure the developer trace in the following ways:
● Changing the database trace level for the dev_webdisp component of the webdispatcher service The default trace level is ERROR. ● Changing (or adding) the property rdisp/trace in the [profile] section of the webdispatcher.ini configuration file. Possible values are 0, 1, 2, and 3.
Database Trace
The database trace files for the Web Dispatcher contain secondary information related to the Web Dispatcher's integration into the SAP HANA integration system (start/stop, configuration changes, and so on).
The database trace files are:
● webdispatcher_
You can configure the database trace by changing the trace level for the webdispatcher component of the webdispatcher service.
SAP HANA Database Explorer 68 PUBLIC Analyzing Performance Header Trace
The header trace allows you to analyze HTTP requests and responses efficiently since it contains only the request data and no information about the internal workings of Web Dispatcher.
You can activate the header trace by adding the property icm/http/trace_info in the [profile] section of the webdispatcher.ini configuration file and setting the value to true. The trace level is false by default.
Header trace information is written to the dev_webdisp trace file.
HTTP Access Log
To monitor all HTTP(s) requests processed in an SAP HANA system, you can set up the internal Web Dispatcher to write a standardized HTTP log for each request.
To configure the Web Dispatcher to log all HTTP(s) requests, you add the property icm/http/logging_0 to the [profile] section of the webdispatcher.ini configuration file, specifying the following value:
PREFIX=/, LOGFILE=$(DIR_INSTANCE)/trace/access_log-%y-%m-%d, MAXSIZEKB=10000, SWITCHTF=day, LOGFORMAT=SAP
The access log file is access_log-
Example
Sample log file entry: [26/Nov/2014:13:42:04 +0200] 10.18.209.126 BOB - "GET /sap/xse/ test/InsertComment.xsjs HTTP/1.1" 200 5 245
The last three numbers are the HTTP response code, the response time in milliseconds, and the size in bytes. For more information about logging and alternative log formats, see the Internet Communication Manager (ICM) documentation on SAP Help Portal.
Related Information
Database Trace (Basic, User-Specific, and End-to-End) [page 53] rdisp/TRACE* Parameters icm/HTTP/trace_infoicm/HTTP/trace_info icm/HTTP/logging_
SAP HANA Database Explorer Analyzing Performance PUBLIC 69 5.4 Analyzing Statement Performance
Analyzing statement performance helps you understand performance issues of a query execution and other query execution aspects of the SAP HANA database.
The following sections provide an overview of the SQL analyzer tool:
What is the SQL analyzer tool?
The SQL analyzer is a query performance analysis tool of SAP HANA. The tool can be used to view detailed information on each query execution and can help you evaluate potential bottlenecks and optimizations for these queries.
How can you access the SQL analyzer?
You can open the SQL analyzer from the SAP HANA cockpit or from the SAP Web IDE for SAP HANA.
● From the SAP HANA cockpit there are eight ways to open the SQL Analyzer: ○ Use the Expensive Statements page. Open the Monitor expensive statements link from the Monitoring link list. The Expensive Statements Trace page opens, allowing you to identify which SQL statements require a significant amount of time and resources. Each statement string is provided with a More link, which opens the Full SQL Statement dialog. Click Open in SQL Analyzer to open the selected query with the SQL analyzer tool. ○ Use the SQL Plan Cache page. Open the Open SQL plan cache link from the Monitoring link list. The SQL Plan Cache page opens, allowing you to manage registered statement hints. Each statement string is provided with a More link, which opens the Full SQL Statement dialog. Click Open in SQL Analyzer to open the selected query with the SQL analyzer tool. ○ Using the Statement Hints page. Open the Statement Hints page by clicking on the Statement Hints section of the Manage SQL Performance tile, or by clicking the Manage statements hints link from the Database Administration link list. The Statement Hints page opens, allowing you to manage registered statement hints. Each statement string is provided with a More link, which opens the Full SQL Statement dialog. Click Open in SQL Analyzer to open the selected query with the SQL analyzer tool. ○ Use the Plan Stability page. Open the Plan Stability page by clicking on the Plan Stability section on the Manage SQL Performance tile, or by clicking the Manage plan stability link from the Database Administration link list. The Plan Stability page opens. Each captured plan is provided with a More link next to the statement string, which opens the Full SQL Statement dialog. Click Open in SQL Analyzer to open the selected query with the SQL analyzer tool. ○ Use the Plan Trace page. Open the Plan Trace page by clicking on the Plan Trace section on the Manage SQL Performance tile, or by clicking the Plan trace link from the Alerting and Diagnostics link list. The Plan Trace page opens. Each traced plan is provided with a More link next to the statement string, which opens the Full SQL Statement dialog. Click Open in SQL Analyzer to open the selected query with the SQL analyzer tool.
SAP HANA Database Explorer 70 PUBLIC Analyzing Performance ○ Use the Saved Plans page. Open the Saved Plans page by clicking on the Saved Plans section on the Manage SQL Performance tile, or by clicking the Manage saved plans link from the Alerting and Diagnostics link list. The Saved Plans page opens. Each saved plan is provided with a More link next to the statement string, which opens the Full SQL Statement dialog. Click Open in SQL Analyzer to open the selected query with the SQL analyzer tool. ○ Use the Workload Analysis (based on thread sampling) page. Open the Workload Analysis (based on thread sampling) page by clicking on the chart on the Analyze Workloads tile. The Workload Analysis page opens. In the SQL Statements page, click on any entry to open the Current Selection dialog. Click Open in SQL Analyzer to open the selected query with the SQL analyzer tool. ○ Use the Execute SQL link from the Database Explorer link list. On the Overview page, open the Execute SQL link. The SAP HANA database explorer opens. In the menu of the Analyze button, click Analyze SQL to open the SQL analyzer. ● From the SAP Web IDE for SAP HANA you can open the SQL analyzer in a SQL Console by clicking Analyze SQL in the menu of the Analyze button.
Which views are supported by the SQL analyzer?
The following views are supported by the SQL analyzer:
SQL Analyzer Views
View Description
Overview This view provides an overview of the query execution in cluding metadata for the analysis. It displays the following KPIs:
● Time ● Dominant Operators ● Statistics ● SQL Performance Recommendations
To get more information on the KPIs, see Analyze Statement Performance.
Plan Graph This view provides graphical guidance to help you under stand and analyze the execution plan of a SQL statement. In case of SQLScript, the SQLScript definition is also displayed.
SQL This view displays the complete SQL string that is analyzed.
Operators This view provides a list of operators used during query exe cution and includes additional details about each operator, which can be used for analysis.
Timeline This view provides a complete overview of the execution plan based on the visualization of sequential time-stamps.
SAP HANA Database Explorer Analyzing Performance PUBLIC 71 View Description
Tables in Use This view provides a list of tables used during query execu tion and includes further details on tables, which can be used for further analysis. It can be used to understand which tables are needed to fulfill a given SQL statement execution.
Table Accesses This view provides details on the table accesses performed during the processing of a SQL statement, which can be used for analysis.
Compilation Summary This view provides details on the query compilation process. It can be used to understand how much time was spent on which operation, which cost-based information was used, and what the plan properties are.
Recommendations This view shows details on the provided recommendation al lowing you to understand the reasoning for it.
Related Information
Analyze Statement Performance [page 72]
5.4.1 Analyze Statement Performance
The SQL analyzer is used to analyze statement execution performance.
Context
From the SAP HANA cockpit the SQL analyzer can be opened using the Monitor expensive statements link, the Plan Trace link, or the SAP HANA database explorer. You can also open the tool from the SAP Web IDE for SAP HANA. For more information on how to open the SQL analyzer, see section How can you access the SQL analyzer? in Analyzing Statement Performance.
Procedure
1. Open the SQL analyzer.
The SQL Analyzer page opens, displaying the following views:
SAP HANA Database Explorer 72 PUBLIC Analyzing Performance ○ Overview ○ Plan Graph ○ SQL ○ Operators ○ Statement Statistics (SQLScript only) ○ Timeline ○ Tables in Use ○ Table Accesses ○ Compilation Summary ○ Recommendations 2. Open the Overview tab to view important KPIs required to begin a performance analysis before going into the complex details.
KPI Description
KPI Description
Time The initial compilation time
The elapsed time indicating the total response time from the query execution request time to the end time of the query execution
Dominant Operators Operators sorted by their execution time
You can navigate to the Operators tab on the table below by clicking Open Operators on the bottom of the card. This will show the operators sorted in descending order by exe cution time.
Statistics System version: The version of the system where the exe cution occurred
Tables in use: Total number of tables touched by any oper ators during execution
You can navigate to the Tables in Use tab on the table be low by clicking this line.
Result Records: The final result record count
Memory Allocated: Total memory allocated for executing the statement
Distribution: Number of SAP HANA index servers that are related to the query execution
The name of the host
SQL Performance Recommendations Recommendations on how you can improve the perform ance of SQL-related operations.
SAP HANA Database Explorer Analyzing Performance PUBLIC 73 3. Open the Plan Graph tab to understand and analyze the execution plan of an SQL statement. It displays a visualization of a critical path based on inclusove execution time of operators and allows you to identify the most expensive path in a query execution plan.
In case of a SQLScript, the Plan Graph displays its complete definition. To retrieve the information in a text format, you can copy the definition by clicking the copy icon.
In the Plan Graph tab you can open the Detail Properties view by clicking one of the operators. This view offers detailed information on the operator such as name, location, ID, summary.
You can open the edge infromation detail by clicking one of the links between the operators. This view offers further information on the edge values, such as target, source, output cardinality, fetch call count, and estimated output cardinality.
Furthermore, you can configure plan graph settings. You can set the color of the nodes by type or location, and choose to show either physical or logical inner plans. 4. Open the SQL tab to get the complete view of the SQL statement string that is being analyzed. 5. Open the Operators tab to pinpoint specific operators of interest.
The view lists characteristics of all operators and supports: ○ Display of various KPIs, for example physical (whether an operation is a real, physically executed one), offset, execution time, CPU time ○ Setting of filters along all the columns/KPIs ○ Display of the number of operators within the filtered set ○ Immediate aggregated information (max, min, sum, and so on) for the same KPIs on the filtered operator set ○ Detailed display of all operators within the filtered set 6. Open the Tables in Use tab for an overview of which tables have been used during the processing of a statement.
The view displays the following information: ○ The name of the table ○ The host and port of the table's partition in the Location column ○ The partition number of the table's partition in the Partition column ○ The maximum possible amount of data processed for a given table during the execution of a statement, including the possibility of multiple accesses, in the Max. Entries Processed column ○ How often a table has been accessed during statement execution in the Number of accesses column ○ The maximum processing time across the possibly multiple table accesses in the Maximum processing time column 7. Open the Statement Statistics to view a set of statistics (SQLScript only) for each SQL statement involved in the procedure. This set of statistics provides a good starting point for analyzing the performance of a procedure as it lets users easily drill-down the most expensive SQL statement.
The following information is available for each statement so that users can sort the column (criterion) of their interest to find the most expensive statement: SQL Statement, Line Number, Execution Count, Execution Times, Compilation Times, Memory Allocated, Result Record Count, Explain Plan Result, and Procedure Comment. 8. Open the Timeline tab to get a complete overview of the execution plan based on the visualization of sequential time-stamps. The operator tree table displays hierarchical parent-child relationships and container-inner plan relationships. Based on the operators, the timeline chart shows the operations executed at different time intervals.
SAP HANA Database Explorer 74 PUBLIC Analyzing Performance 9. Open the Table Accesses tab to see the details on the table accesses performed during the processing of a statement.
The view displays the following information:
○ The Offset time for accessing the table ○ The name of the table ○ The Conditions that affect the table accesses ○ The Processing Time ○ The amount of entries processed during an operation in the Entries Processed column ○ The host and port of the table's partition in the Location column ○ The operator’s unique ID in a query execution result in the Operator Id column ○ The name of the operator ○ The detail information of an operator in the Details column ○ The partition number of the table's partition in the Partition column
For cached plans, the table displays the following information: Inclusive Estimated Cost, Exclusive Estimated Cost, and the Estimated Output Size.
Optional: To get aggregated information for each column, choose the aggregator functions in the drop- down menu under the column name. If an aggregator is chosen, you can see More information for your chosen query.
Optional: To refine results, click on Filters on the upper right corner. The Filters page appears, where you can choose the information type, operator, and enter values according to which you wish to filter the Table Accesses. Choose OK to confirm. If you want to remove the filters you selected, go to the Filters page and choose to Restore to defaults.
Optional: To sort the results, click the sorting icon next to the Filters button and choose the sorting order.
Optional: To customize the columns displayed in the information list, click on the settings icon on the upper right corner and choose to hide or display the desired columns. 10. Open the Compilation Summary tab to view details on the query compilation process, including compilation time breakdown, cost-based optimization details, and plan properties. 11. Open the Recommendations tab to see the details for each provided recommendation. This allows you to easier understand the reasoning behind the recommendation for SQL query optimization. 12. Optional: Re-execute the SQL query by clicking the Re-execute button on the top right corner. If the query is parameterized, you can change the parameter values.
With a parameterized query, the Input Parameters appears, prompting you to enter your desired parameters in the Parameter tab. You can list the parameter values and separate them by a comma, or enter and edit them individually. Where applicable, you can check the Empty value box. The values you entered are reflected in the SQL string that you can see in the SQL Statement tab. Click on Execute SQL to analyze the SQL string according to the parameter values you entered and see the result on the SQL Analyzer page.
Related Information
Analyzing Statement Performance [page 70]
SAP HANA Database Explorer Analyzing Performance PUBLIC 75 5.5 Analyzing SQL and Saving Plans
This function of the SAP HANA cockpit allows you to save SQL plans, download them, and load a file from the SAP HANA database.
There are two ways in which you can record SQL plans for future reference with the SAP HANA cockpit:
● You can save them within the SAP HANA database filesystem, and ● Download the saved SQL plans as local PLV files on your personal computer.
Both of these options are available with this functionality.
Additionally, you can also load PLV files into the SQL Analyzer tool from the trace folder in the SAP HANA database.
Related Information
Save Plans as Files [page 76] Download Files [page 78]
5.5.1 Save Plans as Files
You can save SQL plans within the SAP HANA database.
Prerequisites
Since this functionality can be accessed from different performance management and monitoring tools within the SAP HANA cockpit, please check the privileges they might require respectively.
You've navigated to the Database Overview page of the database you want to manage. See Getting to the Database Overview Page in the SAP HANA Administration with SAP HANA Cockpit guide.
Context
Saving SQL plans helps you record them as PLV files in the trace folder within the SAP HANA database.
You can save SQL plans from the following performance monitoring tools:
● Expensive Statements ● Plan Stability ● SQL Analyzer
SAP HANA Database Explorer 76 PUBLIC Analyzing Performance ● Statement Hints
Procedure
1. On the Database Overview page, with the Administration or All view selected, click the Statement Hints section of the Manage SQL Performance card.
You can also save a SQL plan from the Expensive Statement tab of the Monitor Statements page. Open Monitor Statements by navigating to the SQL Statementscard on the Monitoring or All view of your Database Overview. a. In the table view, select the More option on your desired statement string.
A dialogue appears offering several options. b. Choose to Analyze SQL and Save Plan.
A window appears, displaying the SAP HANA database file folder, where the SQL plan is being saved, and prompting you to enter a prefix for a filename. c. To finalize the saving process, enter a desired prefix for a filename of your saved SQL plan and confirm. 2. Choose whether to run the analysis as a background activity. 3. Save a SQL plan from the SQL Analyzer by choosing the Execute and Save option from the Execute menu on the upper right corner of the page.
Note
Choosing the Execute option will not save the plan.
On the bottom of the screen, the filename appears, along with the SAP HANA database folder, where the SQL plan would be saved. On the upper right corner, you can select to Download the file. The dialogue also allows you to Copy the path of the SQL plan.
For more information, see, Download Files.
Related Information
Analyzing SQL and Saving Plans [page 76] Monitoring and Analyzing with the Statements Monitor Managing Plan Stability Analyzing Statement Performance [page 70] Managing Statement Hints Download Files [page 78]
SAP HANA Database Explorer Analyzing Performance PUBLIC 77 5.5.2 Download Files
You can download saved SQL plans as local files to your hard drive.
Prerequisites
To download files, you have to have saved SQL plans in the SAP HANA database. For more information, see, Save Plans.
Since this functionality can be accessed from different performance management and monitoring tools within the SAP HANA cockpit, please check the privileges they might require respectively.
You've navigated to the Database Overview page of the database you want to manage. See Getting to the Database Overview Page in the SAP HANA Administration with SAP HANA Cockpit guide.
Context
Downloading SQL plans helps you share the SQL plans as a PLV file with others.
You can download SQL plans from the Saved Plans and the SQL Analyzer tools.
Procedure
1. On the Database Overview page, with the Administration or All view selected, click the Saved Plans section of the Manage SQL Performance card. 2. Download SQL plans as local files to your hard drive from the Saved Plans tool by choosing the download icon next to the desired statement string. 3. Download SQL plans as local files to your hard drive from the SQL Analyzer tool by clicking the Download button on the upper right corner of the executed parameterized query.
A dialogue appears that allows you to Download the file to your hard drive.
For more information, see, Save Plans and Analyze Statement Performance.
Related Information
Analyzing SQL and Saving Plans [page 76] Save Plans as Files [page 76] Manage Saved Plans Analyzing Statement Performance [page 70]
SAP HANA Database Explorer 78 PUBLIC Analyzing Performance 5.6 Analyze Procedure and Function Performance
Analyze a procedure or function written in SQLScript to search for patterns indicating problems in code quality, security or performance.
Prerequisites
You must be connected to a HANA database that has the SQLScript Code Analyzer.
You must have the required database permissions to run the SQLScript Code Analyzer.
Context
The SQLScript Code Analysis Results editor only shows the first 1,000 results.
Procedure
1. Choose from one of the following options:
Option Action
To analyze all procedures and functions for a database Right-click on the database or schema and click Analyze or schema SQLScript Code.
To analyze all procedures or all functions for a database Right-click on the Procedures folder or the Functions folder or schema of the database or schema and click Analyze SQLScript Code.
To analyze an individual procedure or function ○ Open the list of procedures or functions by clicking the Procedures folder or the Functions folder. Right- click a procedure or function in the catalog browser list and click Analyze SQLScript Code. ○ Click the procedure or function to open its definition and then click Analyze SQLScript Code. ○ Right-click on the procedure or function and click Analyze SQLScript Code.
To analyze a specific set of procedures or functions Open the list of procedures or functions by clicking the Procedures folder or the Functions folder. Click on the pro cedures or functions that you want to analyze, then right- click and click Analyze SQLScript Code.
The SQLScript Code Analysis Results editor opens and the results of the analysis are loaded.
2. (Optional) Search for a specific result using the search bar or download the results in CSV format by clicking the download button ().
SAP HANA Database Explorer Analyzing Performance PUBLIC 79 3. (Optional) Right-click on a result and click Open CREATE Statement to open the procedure or function in a code editor where the problematic portion of the code is marked.
5.7 View Execution Plans for SQL Statements, Procedures, and Anonymous Blocks
View the details of a compiled execution plan for a SQL statement, procedure, or an anonymous block.
Context
Running Explain Plan generates the SQLScript engine's execution plan for a given statement, procedure or anonymous blocks. The results of the execution plan are stored in a global temporary table. For SQL statements, the results are stored in the EXPLAIN_PLAN_TABLE temporary table. For procedures and anonymous blocks, results are stored in the EXPLAIN_CALL_PLANS temporary table, and only if you are using HANA 2.0 or higher.
Procedure
1. Enter your SQL statement or procedure in the SQL console.
You can enter multiple SQL statements at once.
2. Click Analyze Explain Plan .
Results
The plan information for each statement is displayed separately. The results are visible only within the session where the EXPLAIN PLAN call is executed.
Related Information
Query Plan Analysis
SAP HANA Database Explorer 80 PUBLIC Analyzing Performance 6 View Diagnostic Files in the SAP HANA Database Explorer
Diagnose and analyze errors in an SAP HANA database by viewing the relevant diagnostic files in the SAP HANA database explorer.
Context
In the catalog browser, diagnostic files for online databases are grouped by host and then by service. In a multi- host system, check each host folder to view all diagnostic files associated with a particular service.
Procedure
Choose one of the following options:
Option Description
View diagnostic files Open the Database Diagnostic Files folder of your database, then right-click the diagnostic file that for a database that is you want to examine and click Show Files to open the file in an editor. If the trace file is binary, then online and available it cannot be opened in the database explorer, but can be downloaded. The Database Diagnostic Files folder contains all diagnostic files that are available through the database's M_TRACEFILES system view.
View diagnostic files Open the Host Diagnostic Files folder of your cockpit database, then right-click the diagnostic file for a cockpit data that you want to examine and click Show Files to open the file in an editor. If the trace file is binary, base that is either then it cannot be opened in the database explorer, but can be downloaded. The Host Diagnostic online or offline Files folder contains all diagnostic files that have been configured for the SAP Host Agent.
For more information about configuring the SAP Host Agent, see the SAP Host Agent documenta tion.
The cockpit database must have valid SAP Control Credentials set in the cockpit. If the user has not set valid SAP Control Credentials, then an error is returned.
View diagnostic files Under the Database Diagnostic Files folder of your database, right-click the folder of the tenant da for tenant databases tabase that you want to view trace files for, and then click Show Files to open the file in an editor. in an MDC system Note
You must be connected to the system database as the SYSTEM user.
SAP HANA Database Explorer View Diagnostic Files in the SAP HANA Database Explorer PUBLIC 81 Related Information
Collecting Diagnosis Information for SAP Support
6.1 Viewing the Trace File List
See all the trace files in your system.
Seeing traced files currently in your system is useful for SAP HANA database monitoring and analysis.
To view the trace file, open the SAP HANA database explorer. Right-click the desired host folder, and click Show Files.
The trace file list opens, showing all traced files currently in the system. You can also see their metadata such as the host, file name, size, and the time the file was modified.
To support monitoring and analysis, you can perform the following actions on the trace file list:
● Define the sorting order of the traced files ● Filter the results according to a desired parameter ● See the traced file’s contents by selecting its row from the table
Note
You cannot see the full contents of a traced file. It only loads partial content from the start or the end of a file.
● In the contents view, you can choose to show the start or the end of the traced file ● In the contents view, you can input lines up to 10MB in size.
6.2 View Diagnosis Files of an Unavailable Tenant Database
If a tenant database is unavailable, for example because it's stopped or experiencing major performance problems, the tenant database administrator can't access diagnosis files. In this case, you as the system administrator can access the diagnosis files of the tenant database from the system database using the SAP HANA database explorer.
Procedure
Open the Host Diagnostic Files folder of your cockpit database, then click the diagnostic file that you want to examine to open it in an editor. The Host Diagnostic Files folder contains all diagnostic files that have been configured for the SAP Host Agent.
SAP HANA Database Explorer 82 PUBLIC View Diagnostic Files in the SAP HANA Database Explorer Note
You cannot open binary trace files (marked with a binary icon) in the database explorer. You can only download binary trace files.
For more information about configuring the SAP Host Agent, see the SAP Host Agent documentation.
The cockpit database must have valid SAP Control Credentials set in the cockpit. If the user has not set valid SAP Control Credentials, then an error is returned. The diagnosis files of the system database are displayed.
Next Steps
If more detailed diagnosis information is required (for example for SAP Support), you can trigger the collection of a full system information dump for tenant databases. For more information, see Collecting Diagnosis Information for SAP Support in the SAP HANA Administration Guide.
Related Information
Add a Database to the SAP HANA Database Explorer [page 10] View Diagnostic Files in the SAP HANA Database Explorer [page 49] SAP Host Agent
SAP HANA Database Explorer View Diagnostic Files in the SAP HANA Database Explorer PUBLIC 83 7 Importing, Exporting, and Accessing Data
Import or export schemas and database objects and create and manage remote sources and virtual objects.
7.1 Create a Remote Source
Use SAP HANA database explorer to create a remote source to another database.
Prerequisites
● You have the CREATE REMOTE SOURCE system privilege. ● To create the remote source by using a DSN entry, it must already exist in the ODBC.ini file. ● The remote data source must be accessible from your the network.
Context
The connection properties depend on your adapter type and connection mode.
Smart Data Access Connection Properties
Connection Properties Description
Data Source Name The DSN as defined in the odbc.ini file.
Configuration File ● For SAP Event Stream Processor and SAP Streaming Analytics, specify property_esp.ini. ● For SAP MaxDB, specify property_maxdb.ini. ● For SQL Server, specify property_mss.ini. ● For IBM DB2, specify property_db2.ini. ● For Oracle, specify property_orcl.ini. ● For IBM Netezza, specify property_db2.ini. ● For Google BigQuery, specify property_bq.ini.
Driver The library name containing the driver for the specified adapter.
Server/ServerNode The SAP HANA server. For failover, list the failover server name, separated by a comma. For exam ple, server_name1:30015,failover_server_name1:30015.
SAP HANA Database Explorer 84 PUBLIC Importing, Exporting, and Accessing Data Connection Properties Description
Port The server port number.
Authentication Mode An optional Rserve authentication mode.
SSL mode Specifies whether to use SSL. Specify use SSL or no SSL.
Database Name The name of the database you are creating the remote source for.
DML Mode Specifies if the remote source is readwrite (default), or readonly.
Extra Adapter Proper Additional connection properties. Choose one of the following: ties SAP (Session Connection Information Only) HANA sessionVariable:
SAP Specify the additional properties to complete the remote connection as follows: IQ ServerName=
For example, the additional properties to connect to the demo database would be:
ServerName=
CommLinks=tcpip(host=
SAP (For failover only) Enables automatic failover for the remote source. Enter: ASE HASession=1;AlternateServers=
WebHDFS URL The default address of the namenode web user interface.
WebHCAT URL The fully qualified domain name of the host where the WebHCat server is located. The default port is 50111.
Smart Data Integration Connection Properties
Connection Properties Description
Application Server The server of the application.
Client The name of the client.
Host The name of the computer where the client is located.
Instance Number The instance number of the client.
Port Number The port number of the computer where the client is located.
System Object Prefix The prefix for object names of the specified database system.
SAP HANA Database Explorer Importing, Exporting, and Accessing Data PUBLIC 85 Procedure
1. In the SAP HANA database explorer, right-click the Remote Sources object in your database catalog and click New Remote Source. 2. Specify a remote source name, adapter name, and, optionally, a source location. The Source Location field defaults to indexserver for SDA adapters, and dpserver for smart data integration. 3. Specify an adapter version and connection mode. Choose Data Source Name if you are using a DSN entry. Otherwise, choose the default setting, Adapter Properties. 4. Fill in the other required connection property fields, which are marked with an *. 5. Specify one of the following credential modes (enter your user name and password as required):
Technical User All connections to the remote data source share the same credentials.
Secondary One set of credentials is used per data source. Credentials At least one set of secondary credentials should exist before creating the remote source.
None No credentials are required to connect to the remote data source.
6. Click OK.
Edit a Remote Source
Context
View the properties of a remote source and edit the parameters used to create the remote source.
Procedure
1. In your catalog browser, click Remote Sources to bring up an item list of your remote sources. 2. Click the remote source that you want to edit to open the remote source editor. 3. Click Edit and make the changes to your remote source properties. 4. Click Save.
The system saves the change and then tests the new connection properties. If the connection fails, a message appears. If defined, all filters are reset and the remote object list is cleared.
Related Information
Managing Secondary Credentials
SAP HANA Database Explorer 86 PUBLIC Importing, Exporting, and Accessing Data Managing Single Sign-On (SSO) with Kerberos Managing Single Sign-On (SSO) with Kerberos SAP HANA Smart Data Access Managing Virtual Tables
7.2 Edit a Remote Source
View the properties of a remote source and edit the parameters that were used to create the remote source.
Prerequisites
The remote data source must be accessible from your the network.
Procedure
1. In your catalog browser, click Remote Sources to bring up an item list of your remote sources. 2. Click the remote source that you want to edit to open the remote source editor. 3. Click Edit and make the changes to your remote source properties. 4. Click Save.
The system saves the change and then tests the new connection properties. If the connection fails, then a message appears. If defined, then all filters are reset and the remote object list is cleared.
Related Information
Managing Secondary Credentials Managing Single Sign-On (SSO) with Kerberos Managing Single Sign-On (SSO) with Kerberos SAP HANA Smart Data Access Managing Virtual Tables
SAP HANA Database Explorer Importing, Exporting, and Accessing Data PUBLIC 87 7.3 Create Virtual Objects (Smart Data Access)
Create a virtual object from a remote source object.
Prerequisites
You must either be the creator of the remote source or have the CREATE VIRTUAL TABLE object privilege on the remote source.
Procedure
1. In the catalog browser, click Remote Sources.
A list of remote sources appears in the catalog browser item list. 2. Click a remote source from the item list to open the remote source editor. 3. Use the Search functionality to return a set of remote objects that is displayed in the editor table as a flat list. 4. Select one or more remote object(s) and click Create Virtual Object(s). 5. Name your virtual object(s).
If you select only one remote object, then either use the default virtual object name or give it a new name. If you select more than one remote object, then you can either leave the Object Names Prefix field blank so all objects are created with their default names, or you can specify a prefix that is added to the name of the new virtual objects. 6. Specify the schema to create the virtual object(s) in. 7. Click Create.
Related Information
Managing Secondary Credentials Managing Single Sign-On (SSO) with Kerberos Managing Single Sign-On (SSO) with Kerberos SAP HANA Smart Data Access Managing Virtual Tables
SAP HANA Database Explorer 88 PUBLIC Importing, Exporting, and Accessing Data 7.4 Create Virtual Objects (SAP HANA Smart Data Integration)
Create a virtual object from a remote source object.
Prerequisites
You must either be the creator of the remote source or have the CREATE VIRTUAL TABLE object privilege on the remote source.
Context
For more information about smart data integration, see https://help.sap.com/viewer/p/ HANA_SMART_DATA_INTEGRATION.
Procedure
1. In the catalog browser, click Remote Sources.
A list of remote sources appears in the catalog browser item list. 2. Click a remote source from the item list to open the remote source editor. 3. Use the Search functionality to return a set of remote objects displayed in the editor as a flat list.
Note
The search functionality is only enabled if a dictionary is created for a remote source. A dictionary is a local copy of the objects in a remote source. Searching is performed only on dictionaries for performance purposes.
Use the Dictionary section of your remote source editor to create, refresh, or clear your dictionary.
4. Select one or more remote object(s) and click Create Virtual Object(s). 5. Name your virtual object(s).
If you select only one remote object, then either use the default virtual object name or give it a new name. If you select more than one remote object, then you can either leave the Object Names Prefix field blank so all objects are created with their default names, or you can specify a prefix that is added to the name of the new virtual objects. 6. Specify the schema to create the virtual object(s) in. 7. Click Create.
SAP HANA Database Explorer Importing, Exporting, and Accessing Data PUBLIC 89 7.5 Import Schemas, Tables, and Other Catalog Objects
Import catalog objects, including schemas, into your database by using the SAP HANA database explorer.
Prerequisites
● Import data must be compressed in .tar.gz format, which is provided during the database explorer export. Data exported by the SAP HANA studio must be compressed to .tar.gz before it can be imported. ● The database objects being imported must have been exported by using the export feature in the database explorer. ● In the destination database you must have the INSERT/UPDATE, DROP, or CREATE object privileges for the destination catalog objects and you must have the IMPORT system privilege. By default, these privileges are not granted to an HDI container user; they must be granted. ● If you are importing binary files, then those files must have been generated on an SAP HANA system that has the same endianness as the destination system.
Context
You cannot import a database object larger than 2 GB. If you are importing a database object larger than 1 GB, then import the object to the SAP HANA computer rather than to the local computer.
Procedure
1. In the SAP HANA database explorer, right-click the schema that you want to import the objects to, and choose Import Catalog Objects. 2. Specify the directory you're importing the file from and whether you're importing the object from your local computer or an SAP HANA server. If this file is greater than 1 GB, then it must be imported from the same computer as the SAP HANA server to avoid sending large amounts of data across the network. The import fails if the file exceeds 2 GB. 3. Specify the scope of the import by choosing the relevant options:
Option Description
Include Dependent objects of the selected objects are also imported. For example, if a table has any trig dependencies gers or indexes associated with it, then these definitions are imported.
Include table data Import the table data along with the table definitions.
If you deselect this option, then only the table definitions are imported.
SAP HANA Database Explorer 90 PUBLIC Importing, Exporting, and Accessing Data Option Description
Replace existing If objects with the same names already exist in the destination database, then they are overwrit objects ten by the objects being imported.
Fail import if it If you are including object data when importing a catalog object, then selecting this checkbox contains invalid data ensures that your import is canceled if any of the object data is incomplete or corrupt.
Number of parallel Increasing the number of threads can speed up the import and affect database performance. threads Consider the following guidelines when choosing the number of threads to use: ○ For a view or procedure, use two or more threads, up to the number of dependent objects. ○ For a whole schema, consider using more than ten threads, up to the number of CPU cores in the system. ○ For an SAP BW or SAP ERP system with tens of thousands of tables, using many threads is reasonable (up to 256).
4. Click Import.
Results
The catalog objects are imported. The length of time that the export process takes depends on the number of objects being imported and the scope of the import.
You can monitor the progress of a running import with the M_IMPORT_BINARY_STATUS monitoring view.
Related Information
Permissions for Container Objects Roles (.hdbrole) Export Schemas, Tables, and Other Catalog Objects [page 94] IMPORT Statement (Data Import Export) M_IMPORT_BINARY_STATUS System View Import ESRI Shapefiles Using SQL Commands
7.6 Import Data Into a New or Existing Table
Import data from your local system into a new or existing database table.
Prerequisites
You cannot import CSV files larger than 200 MB.
SAP HANA Database Explorer Importing, Exporting, and Accessing Data PUBLIC 91 The file content must follow the data type format supported by SAP HANA as documented in the SAP HANA SQL and System Views Reference guide.
Context
Import data from a comma-separated value (CSV) file.
Unlike using the IMPORT statement, which only allows you to import data if you are creating or replacing a table, this feature allows you to add rows of data to an existing table.
Procedure
1. Right-click on one of the following to access the context menu: your database, your database's Tables icon, or the table you want to import the data to. 2. In the context menu, click Import Data.
The import wizard opens. 3. Configure your Import Properties. a. If the first row of your file contains a header, then leave File has header in first row checked (the default). If the first row of your file contains data, then un-check the box.
Note
If you un-check the File has header in first row option, then the first row of your file is considered data content and must contain data in every column.
b. Choose a file to import your data from. c. Choose a schema to import your data to. d. Choose a new or existing table to import your data to.
Note
If you are importing the data into an HDI container or an Application Managed Service Instance, then you can only import your data into an existing table.
If you are importing your data into an SAP HANA single or multitenant database, then you can import your data into a new table or add data to an existing table.
4. Click Step 2. 5. Configure the mapping for the new table. a. If you are creating a new table, then specify your table type and column names and properties, such as data type and column order. b. If you are importing your data to an existing table, then configure the source column names for the target columns.
When dragging a column into the table, you must drag it either directly above or below another column. 6. Specify the type of error handling for the server during the import process.
SAP HANA Database Explorer 92 PUBLIC Importing, Exporting, and Accessing Data 7. Click Show Import Summary to view a preview of your import. 8. Click Import Into Database.
Results
The data is imported into the specified table and the import progress is displayed on the Import Status page. Press Cancel at any time to roll back the import operation.
7.7 Import HDI Containers
Import an HDI container from a local computer.
Prerequisites
You must have the HDI Container Group Administrator permission for at least one container group in the database.
The HDI container cannot contain tables bigger than 2 GB.
Context tbd
Procedure
1. Right-click your database and click Import HDI Container. 2. Select a .tar.gz file from your local computer to import and click Upload File. 3. Confirm that you want to upload the file to a staging table by clicking Upload.
You can view the upload progress in the Import HDI Container tab. 4. Once the file has completed uploading to a staging table, give it a new HDI container name and assign it to an HDI container group. 5. Click Import HDI Container and then Import, to confirm the process.
The import operation runs as a background activity. 6. Once the import activity shows the status SUCCESS, your import process has successfully completed and you can delete the background activity.
SAP HANA Database Explorer Importing, Exporting, and Accessing Data PUBLIC 93 7. Delete the background activity and (optionally) the staging table.
Staging tables are saved in your database and are named according to the format: .SAP.HRTT.ImportHDI.
a. Right-click the import background activity and click Delete. b. Select whether to delete just the background activity, or the background activity and the staging table.
Keeping the staging table allows you to reuse it for future imports.
Results
The new container has been imported into the database successfully.
7.8 Export Schemas, Tables, and Other Catalog Objects
Export catalog objects, including schemas, from your database by using the SAP HANA database explorer.
Prerequisites
● You must have the SELECT privilege for the catalog objects that you want to export. ● You must have the EXPORT system privilege.
Context
You cannot export a database object larger than 2 GB. If you are exporting a database object larger than 1 GB, then export the object to the SAP HANA computer rather than to the local computer.
Procedure
1. In the catalog browser, right-click the object that you want to export, and then choose Export Catalog Objects. 2. Specify a file name for the object being exported and choose whether to export the object to your local computer or an SAP HANA server.
SAP HANA Database Explorer 94 PUBLIC Importing, Exporting, and Accessing Data Option Description
Local Choose this option to save the export as a compressed file to a directory on your local machine. Computer To avoid sending large amounts of data across the network, do not use this option when exporting large amounts of table data. Instead choose to export to the same computer as the SAP HANA server. An ex port (as well as an import) will fail if the resulting compressed file is larger than 2GB.
The contents of the compressed file are not encrypted, so do not use this option if your local machine is not secure.
SAP HANA Choose this option to save the export to a directory in the database server's file system. Server If you specify a different directory from the default, then: ○ The directory path must exist. ○ The directory path cannot contain symbolic links. ○ When the database is part of a distributed system, specify a directory on a shared disk. ○ You can specify the backup or the work directory of the database instance, but you cannot specify any another database instance directory. For example, if the database instance is located in the /usr/sap/HDB/HDB00 directory, then you could specify: /usr/sap/HDB/HDB00/ backup or /usr/sap/HDB/HDB00/work as a directory for the export.
The contents of the export are not encrypted.
3. Specify the scope of the export with the following options:
Export option Description
Include Select this option to export the objects as well as any objects that depend on them. For example, dependencies if a table has any triggers or indexes associated with it, then their definitions are exported.
Include table data When exporting tables, select this option to export the data, in addition to the definitions.
Clear this option to export only the table object definitions.
Number of parallel Increasing the number of threads can speed up the export and affect database performance. threads Consider the following guidelines when choosing the number of threads to use: ○ For a view or procedure, use two or more threads, up to the number of dependent objects. ○ For a whole schema, consider using more than ten threads, up to the number of CPU cores in the system. ○ For an SAP BW or SAP ERP system with tens of thousands of tables, using many threads is reasonable (up to 256).
Column table Specify the format to use when exporting tables: format ○ Choose CSV when you are exporting row-store tables or when you must read the contents of the export. ○ Choose Binary to speed up the export time when you are exporting column-store tables.
4. Click Export.
Results
The catalog objects are exported to the specified location. The length of time that the export process takes depends on number of objects being exported and the scope of the export.
SAP HANA Database Explorer Importing, Exporting, and Accessing Data PUBLIC 95 Monitor the progress of a running export by using the M_EXPORT_BINARY_STATUS monitoring view.
Related Information
EXPORT Statement (Data Import Export) Import Schemas, Tables, and Other Catalog Objects [page 90] M_EXPORT_BINARY_STATUS System View
7.9 Export HDI Containers
Export an HDI container as a local file.
Prerequisites
You must have the HDI Container Group Administrator permission for at least one container group in the database.
The HDI container cannot contain tables bigger than 2 GB.
Context
Exporting an HDI container requires two steps:
Preparing the HDI container for Saves the HDI container contents to a staging table. This staging table download is created in your default schema.
Downloading the HDI container as a Downloads the contents of the staging table to your local machine as a file tar.gz file.
Procedure
1. Prepare the HDI container for download. a. Right-click the database and click Export HDI Container. b. On the Export HDI Container tab, pick the HDI container you want to export and click Prepare HDI Container for Download. c. Click Prepare to confirm the HDI container that you want to export.
SAP HANA Database Explorer 96 PUBLIC Importing, Exporting, and Accessing Data 2. Download the HDI container as a local file. a. Double-click the "Prepare HDI Container" background activity and click Download.
The HDI container is downloaded as a tar.gz file. 3. Delete the background activity and (optionally) the staging table.
Staging tables are saved in your database and are named according to the format: .SAP.HRTT.ExportHDI.
Keeping the staging table allows you to reuse it for future imports using the SQL console.
Results
Your HDI container has been successfully downloaded to your computer's default download folder
SAP HANA Database Explorer Importing, Exporting, and Accessing Data PUBLIC 97 8 Important Disclaimer for Features in SAP HANA
For information about the capabilities available for your license and installation scenario, refer to the Feature Scope Description for SAP HANA.
SAP HANA Database Explorer 98 PUBLIC Important Disclaimer for Features in SAP HANA Important Disclaimers and Legal Information
Hyperlinks
Some links are classified by an icon and/or a mouseover text. These links provide additional information. About the icons:
● Links with the icon : You are entering a Web site that is not hosted by SAP. By using such links, you agree (unless expressly stated otherwise in your agreements with SAP) to this:
● The content of the linked-to site is not SAP documentation. You may not infer any product claims against SAP based on this information. ● SAP does not agree or disagree with the content on the linked-to site, nor does SAP warrant the availability and correctness. SAP shall not be liable for any damages caused by the use of such content unless damages have been caused by SAP's gross negligence or willful misconduct.
● Links with the icon : You are leaving the documentation for that particular SAP product or service and are entering a SAP-hosted Web site. By using such links, you agree that (unless expressly stated otherwise in your agreements with SAP) you may not infer any product claims against SAP based on this information.
Beta and Other Experimental Features
Experimental features are not part of the officially delivered scope that SAP guarantees for future releases. This means that experimental features may be changed by SAP at any time for any reason without notice. Experimental features are not for productive use. You may not demonstrate, test, examine, evaluate or otherwise use the experimental features in a live operating environment or with data that has not been sufficiently backed up. The purpose of experimental features is to get feedback early on, allowing customers and partners to influence the future product accordingly. By providing your feedback (e.g. in the SAP Community), you accept that intellectual property rights of the contributions or derivative works shall remain the exclusive property of SAP.
Example Code
Any software coding and/or code snippets are examples. They are not for productive use. The example code is only intended to better explain and visualize the syntax and phrasing rules. SAP does not warrant the correctness and completeness of the example code. SAP shall not be liable for errors or damages caused by the use of example code unless damages have been caused by SAP's gross negligence or willful misconduct.
Gender-Related Language
We try not to use gender-specific word forms and formulations. As appropriate for context and readability, SAP may use masculine word forms to refer to all genders.
Videos Hosted on External Platforms
Some videos may point to third-party video hosting platforms. SAP cannot guarantee the future availability of videos stored on these platforms. Furthermore, any advertisements or other content hosted on these platforms (for example, suggested videos or by navigating to other videos hosted on the same site), are not within the control or responsibility of SAP.
SAP HANA Database Explorer Important Disclaimers and Legal Information PUBLIC 99 www.sap.com/contactsap
© 2020 SAP SE or an SAP affiliate company. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company. The information contained herein may be changed without prior notice.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names mentioned are the trademarks of their respective companies.
Please see https://www.sap.com/about/legal/trademark.html for additional trademark information and notices.
THE BEST RUN