Document Type | Technical Information
Category | Utility
Applicable Product Version | 7FS02PS
Document Number | TUTTI002
Overview
This explains the method to change the prompt for distinguishing DB servers when using tbsql.
This can be used when multiple servers are used, such as in TSC Cascading configurations.
Method
1. Specify TB_SQLPATH in bash_profile
$ ls -alt tbsql.login -rw-rw-r-- 1 rmgr1 rmgr1 108 Feb 7 17:06 tbsql.login $ cat .tibero7_2_2.profile #Tibero 7 ENV -- Omitted -- ####. sql prompt #### #. Specify the path for tbsql.login config file export TB_SQLPATH=/home/rmgr1/ #. Receive DB_MODE as a variable to distinguish whether it is Primary or Standby TB_DB_ROLE=$(tbsql sys/tibero <<EOF select DATABASE_ROLE from v$database; EOF ) if [[ $TB_DB_ROLE == "PRIMARY" ]]; then export TB_DB_ROLE='PRIMARY' elif [[ $TB_DB_ROLE == "CASCADING" ]]; then export TB_DB_ROLE='CASCADING' else export TB_DB_ROLE='STANDBY' fi #. Alias to apply profile alias dbrole='source /home/rmgr1/.tibero7_2_2.profile'
2. Define options to apply when connecting to tbsql (tbsql.login config file settings)
$ cat tbsql.login
set serveroutput on
set lines 130
set pages 1000
define sql_prompt=[$TB_SID]
set sqlp '$TB_DB_ROLE &sql_prompt SQL> '
#-- $TB_DB_MODE = Environment variable for DB_MODE set in .bash_profile
#-- &sql_prompt = TB_SID
3. Apply profile before connecting to tbsql
$ source .tibero7_2_2.profile or $ dbrole
4. Check after connecting to tbsql
$ tbsql sys/tibero tbSQL 7 TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. Connected to Tibero. CASCADING [tibero7_s1] SQL>