Entering content frame

Background documentation Access Using a Database Session Locate the document in its SAP Library structure

Use

A database session is a prerequisite for executing many DBM commands.

Database sessions are opened implicitly by some DBM commands and closed again implicitly once the command has been executed.
To open a database session implicitly, the Database Manager uses the data for the first DBM operator. For this reason, only those database statements for which the first DBM operator is authorized can be executed.

However, if you want to execute several DBM commands consecutively in the same database session or commands that can only be executed by a certain database user, we recommend that you first open the database session explicitly specifying the required database user, execute the relevant DBM commands, and then end the database session again explicitly.

DBM commands that require a database session:

Updating the Optimizer Statistics

sql_updatestat

Displaying Status Information for the Database Instance

info

Executing a Database Statement

db_execute

Ending a Database Session

db_release

Scrolling in the Result Data

db_fetch

Scrolling in the Status Information of the Database Instance

info_next

Opening a Database Session

db_connect

Prerequisites

Note the server authorizations required for the respective DBM commands.

Example

Executing a single DBM command (with implicit opening of a database session)

Logging on to the Database Manager CLI as operator DBM with password DBM, connecting to the database instance HOTELDB, executing the DBM command for displaying the cache information.

dbmcli –d HOTELDB –u DBM,DBM info CACHES

OK

END

Type                 | Accesses             | Successful           | Unsuccessful         | Hit Rate (%)

 

DATA                 | 37028                | 36865                | 163

          | 100

CATALOG              | 19774                | 4682                 | 15092

          | 24

SEQUENCE             | 0                    | 0                    | 0

          |

COMMANDPREPARE       | 138                  | 56                   | 82

          | 0

COMMANDEXECUTE       | 134                  | 134                  | 0

          | 100

CATALOGCACHE         | 3423                 | 3360                 | 63

          | 98

CATALOG              | 0                    | 0                    | 0

          |

Executing several DBM commands in the same database session

Logging on to the Database Manager CLI as user DBA with password DBA, connecting to the database instance HOTELDB, opening a database session with user DBA, password DBA (the database user has to be entered again as otherwise the session would be opened with the data for the first DBM operator),
Displaying the contents of the
TABLES system table (this table is extremely large and you will need to execute further DBM commands in the same database session to scroll through the result):

dbmcli -d HOTELDB -u DBA,DBA

dbmcli on HOTELDB>db_connect DBA,DBA

OK

 

---

dbmcli on HOTELDB>db_execute select * from tables

OK

CONTINUE

'DBA';'DBA';'ALLOCATORSTATISTIC';'SEL+';'SYSTEM';'VIEW';'20040809';'00143346';(n

ull);(null);(null);(null);(null);(null);(null);'';x'00000000000000AD';(null);(nu

ll);(null)

'DBA';'DBA';'CONFIGURATION';'SEL+';'SYSTEM';'VIEW';'20040809';'00143345';(null);

(null);(null);(null);(null);(null);(null);'';x'0000000000000091';(null);(null);(

null)

...

...

...

dbmcli on HOTELDB>db_fetch

OK

CONTINUE

'DBA';'DBA';'DBA_AUDIT_STATEMENT';'SEL+';'SYNONYM';'SYNONYM';'20040809';'0014335

1';(null);(null);(null);(null);(null);(null);(null);'';x'00000000000001E4';(null

);(null);(null)

....

....

....

dbmcli on HOTELDB>db_fetch

...

...

...

 

Leaving content frame