이쁘게 보기 위한

set pagesize 1000  /* page가 14마다 구분되지 않도록 크게 지정한다.                     */
set linesize 300   /* linesize도 record 길이만큼 지정하여 아래로 구분되지 않도록 한다. */

 

출력 제어

-- 해당 컬럼 출력안함 
column [컬럼명] noprint


--  명령이 display되지 않도록 한다. 
set echo off     
-- 조회 결과가 화면에 나오지 않도록 한다.     
set term off

 

 

이전 명령 보는 법 

history 기능 키기 

SQL> set hist on

SQL> HIST[ORY] [n RUN | EDIT | DEL[ETE]] | [CLEAR | LIST]

-- 과거이력 확인 
SQL> history

-- 과거 명령 재수행 
SQL> hist
  1  update t1 set c1 = 10;
  2  commit;
  3  his

SQL> hist 1 run

1 row updated.


-- 수정 
SQL> hist 1 edit 

-- list 옵션은 default
SQL> hist list
  1  update t1 set c1 = 10;
  2  commit;
  3  his

 

 

SQLcl 로 확인 가능 

참고문서 : SQLcl 도구 소개 - 기억을 글로 남기기 (kosate.github.io)

  • 기본 기능
    • 접속정보관리
    • Auto-Formatting 기능제공
    • Query History를 관리
    • 사용자 정의 Command 설정(alias)
    • Liquibase 과 연동하여 데이터베이스 객체 변경관리
    • Inline-Editing기능제공(VI편집기)
    • JavaScript를 사용
    • SQLcl Extention기능 제공 (사용자 정의 명령어를 만들수 있음)
      • DataPump/Data Guard관리 기능
      • OCI 연계기능

 

 

 

Prompt 변경

시간 출력

SQL> set time on
03:27:36 SQL>

 

SQL> SET SQLPROMPT '&_USER.@&_CONNECT_IDENTIFIER.> ' : 접속한User명@오라클SID

SQL> set sqlprompt '&_USER.@192.168.0.72:1521 > '
SYS@192.168.0.72:1521 >

 

 

 

Setting 값 파일로 저장하여 실행시 적용 

glogin.sql 수정 

[oracle@sua-oracle sqlplus]$ cd $ORACLE_HOME/sqlplus

[oracle@sua-oracle sqlplus]$ ls
admin  doc  lib  mesg


[oracle@sua-oracle sqlplus]$ cd admin

[oracle@sua-oracle admin]$ ls
glogin.sql  help  libsqlplus.def  plustrce.sql  pupbld.sql  pupdel.sql



[oracle@sua-oracle admin]$ cat glogin.sql
--
-- Copyright (c) 1988, 2005, Oracle.  All Rights Reserved.
--
-- NAME
--   glogin.sql
--
-- DESCRIPTION
--   SQL*Plus global login "site profile" file
--
--   Add any SQL*Plus commands here that are to be executed when a
--   user starts SQL*Plus, or uses the SQL*Plus CONNECT command.
--
-- USAGE
--   This script is automatically run
--

set time on
set timing on
set linesize 100
set null NULL
set sqlprompt '&_USER.@&_CONNECT_IDENTIFIER.> '
set hist on




>> 수정됨

[oracle@sua-oracle admin]$ sqlplus '/as sysdba'

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 3 03:35:41 2024
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SP2-0158: unknown SET option "'"
03:35:41 SYS@ORCL>
03:35:42 SYS@ORCL>