Document Type | Technical Information
Category | Utility
Applicable Product Versions | 6FS07PS, 7FS02PS
Document Number | TUTTI006
Overview
When connecting to the database with tbsql, if there are tasks to perform before starting the session, you can write them in the tbsql.login file to execute those tasks.
This article provides an example of writing the tbsql.login file and guidance on setting the TB_SQLPATH variable as a reference.
Method
You can specify and use system variables of the tbsql utility in the tbsql.login file.
Note
tbsql -i [user name] / [password] allows you to log in without setting up a tbsql.login file.
Example of Writing a tbsql.login File
1. Move to the directory where you want to create the login file
$ cd [directory] For example, create in /home/tibero/test directory $ cd /home/tibero/test
2. Write the tbsql.login file
$ pwd /home/tibero/test $ vi tbsql.login Or $ vi /home/tibero/test/tbsql.login -- Example of file content set linesize 100 set pagesize 1000 set serveroutput on set sqlp '($TB_SID)SQL> ' set echo on
3. Log in with tbsql and verify settings
$ tbsql [user name]/[password] tbSQL 7 TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. Connected to Tibero. (tibero)SQL> show linesize PARAMETER VALUE ---------------- -------------------------------------------------------------- LINESIZE 100 (tibero)SQL> show pagesize PARAMETER VALUE ---------------- -------------------------------------------------------------- PAGESIZE 1000 (tibero)SQL> show serveroutput PARAMETER VALUE ---------------- -------------------------------------------------------------- SERVEROUTPUT ON, SIZE 1000000 (tibero)SQL> show sqlp PARAMETER VALUE ---------------- -------------------------------------------------------------- SQLPROMPT "($TB_SID)SQL> " (tibero)SQL> show echo PARAMETER VALUE ---------------- -------------------------------------------------------------- ECHO ON
TB_SQLPATH Setting
When connecting with tbsql from a directory where the tbsql.login file exists, the file is read and applied at login; if the file does not exist, it searches the directory set in the TB_SQLPATH variable.
When running scripts with @ or START after connecting with tbsql, it first checks the current directory for the script file; if it does not exist there, it checks the directory set in TB_SQLPATH.
NoteSetting the directory where frequently used scripts in the DB exist can improve convenience.
1. Set the TB_SQLPATH variable in your profile or perform export after connecting as a user
export TB_SQLPATH=[desired path] If set in profile, execute source ~/.bash_profile --Example export TB_SQLPATH=/home/tibero/test
2. Check if the environment variable is applied with echo $TB_SQLPATH
SQL Prompt Setting
-## OS Environment Parameter Setting
After applying the TB_SQLPATH path, create a tbsql.login file in the applied path.
-export TB_SQLPATH = $TB_HOME
Example (--## tbsql.login)
set lines 220 --edit by Kong 2013.02.20 set termout off define new_prompt='nolog' column value new_value new_prompt select host_name || '@Node ' || instance_number || ':'|| instance_name ||':' value from v$instance; set sqlprompt "&new_prompt &_USER &_SID SQL > " set termout on col owner form a12 col PARENT_OBJ_OWNER form a16 col PARENT_OBJ_NAME form a34 col file_name form a60 col text form a120 col ID1_DESC form a30 col ID2_DESC form a30 col name form a36 --col value form a20 col DFLT_VALUE form a10 col RANGE form a14 col DETAIL_DESCRIPTION form a80 col status form a10 col username form a10 col "Sid,Serial" form a12 col IPaddr form a17 col program form a12 col COLUMN_NAME form a20 col INDEX_NAME form a20 col DESC_COLUMN_NAME form a30 col DESC_IDX_NAME form a20