새소식

RDBMS/ORACLE & TIBERO

sqlplus history 사용 (rlwrap)

  • -
728x90
반응형

ORACLE과 TIBERO에서 제공하는 SQL 인터프린터에 히스토리 기능을 추가하여, 방향키로 사용 했던 SQL 가져오기


패키지 매니저를 통해 설치하기
[root@577a568b52a0 ~]# yum install -y epel-release [root@577a568b52a0 ~]# rpm -qi epel-release Name : epel-release Version : 7 Release : 11 Architecture: noarch Install Date: Fri Nov 4 07:56:44 2022 Group : System Environment/Base Size : 24834 License : GPLv2 Signature : RSA/SHA256, Fri May 11 12:21:29 2018, Key ID 24c6a8a7f4a80eb5 Source RPM : epel-release-7-11.src.rpm Build Date : Mon Oct 2 17:45:58 2017 Build Host : buildvm-ppc64le-05.ppc.fedoraproject.org Relocations : (not relocatable) Packager : Fedora Project Vendor : Fedora Project URL : http://download.fedoraproject.org/pub/epel Summary : Extra Packages for Enterprise Linux repository configuration Description : This package contains the Extra Packages for Enterprise Linux (EPEL) repository GPG key as well as configuration for yum. [root@577a568b52a0 ~]# yum install -y rlwrap [root@577a568b52a0 ~]# rpm -qi rlwrap Name : rlwrap Version : 0.45.2 Release : 2.el7 Architecture: x86_64 Install Date: Fri Nov 4 07:57:41 2022 Group : Unspecified Size : 324483 License : GPLv2+ Signature : RSA/SHA256, Wed Sep 28 21:08:30 2022, Key ID 6a2faea2352c64e5 Source RPM : rlwrap-0.45.2-2.el7.src.rpm Build Date : Wed Sep 28 21:01:12 2022 Build Host : buildvm-x86-28.iad2.fedoraproject.org Relocations : (not relocatable) Packager : Fedora Project Vendor : Fedora Project URL : https://github.com/hanslub42/rlwrap Bug URL : https://bugz.fedoraproject.org/rlwrap Summary : Wrapper for GNU readline Description : rlwrap is a 'readline wrapper' that uses the GNU readline library to allow the editing of keyboard input for any other command. Input history is remembered across invocations, separately for each command; history completion and search work as in bash and completion word lists can be specified on the command line. [oracle@2235f66166cf ~]$ rlwrap Usage: rlwrap [options] command ... Options: -a[password prompt] --always-readline[=password prompt] -A --ansi-colour-aware -b <chars> --break-chars=<chars> -c --complete-filenames -C <name|N> --command-name=<name|N> -D <0|1|2> --history-no-dupes=<0|1|2> -e <char|''> --extra-char-after-completion=<char|''> -f <completion list> --file=<completion list> -g <regexp> --forget-matching=<regexp> -h --help -H <file> --history-filename=<file> -i --case-insensitive -I --pass-sigint-as-sigterm -l <file> --logfile=<file> -m[newline substitute] --multi-line[=newline substitute] -M <.ext> --multi-line-ext=<.ext> -n --no-warnings -N --no-children -o --one-shot -O <regexp> --only-cook=<regexp> -p[colour] --prompt-colour[=colour] -P <input> --pre-given=<input> -q <chars> --quote-characters=<chars> -r --remember -R --renice -s <N> --histsize=<N> (negative: readonly) -S <prompt> --substitute-prompt=<prompt> -t <name> --set-term-name=<name> -U --mirror-arguments -v --version -w <N> --wait-before-prompt=<N> (msec, <0 : patient mode) -W --polling -z <filter command> --filter=<filter command> ('rlwrap -z listing' writes a list of installed filters) bug reports, suggestions, updates: https://github.com/hanslub42/rlwrap

 

rpm 다운로드 후 설치하기

1. https://pkgs.org/search/?q=rlwrap
2. https://rhel.pkgs.org/7/epel-x86_64/rlwrap-0.45.2-2.el7.x86_64.rpm.html
3. https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/r/rlwrap-0.45.2-2.el7.x86_64.rpm
해당 URL에서 OS버전에 맞는 EP로 접속 테스트 환경은 CentOS 7.9 기준으로 EP7로 접속하여 다운로드 수행 했습니다.
3번 URL로 접속하여 다운로드 (3번 URL 접속 되지 않을 경우 1번 URL에서 OS 버전에 맞는 파일 다운 받습니다.)

wget을 이용하여 tar 다운로드

[root@2235f66166cf ~]# wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/r/rlwrap-0.45.2-2.el7.x86_64.rpm --2022-11-04 08:34:15-- https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/r/rlwrap-0.45.2-2.el7.x86_64.rpm Resolving download-ib01.fedoraproject.org (download-ib01.fedoraproject.org)... 152.19.134.145, 2600:2701:4000:5211:dead:beef:fe:fed6 Connecting to download-ib01.fedoraproject.org (download-ib01.fedoraproject.org)|152.19.134.145|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 135498 (132K) [application/x-rpm] Saving to: 'rlwrap-0.45.2-2.el7.x86_64.rpm' 100%[=============================================================>] 135,498 210KB/s in 0.6s 2022-11-04 08:34:16 (210 KB/s) - 'rlwrap-0.45.2-2.el7.x86_64.rpm' saved [135498/135498]

 

rpm으로 설치 진행

[root@2235f66166cf ~]# rpm -Uvh rlwrap-0.45.2-2.el7.x86_64.rpm warning: rlwrap-0.45.2-2.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY error: Failed dependencies: /usr/bin/perl is needed by rlwrap-0.45.2-2.el7.x86_64 /usr/bin/python3 is needed by rlwrap-0.45.2-2.el7.x86_64 perl >= 0:5.006 is needed by rlwrap-0.45.2-2.el7.x86_64 perl(AutoLoader) is needed by rlwrap-0.45.2-2.el7.x86_64 perl(Carp) is needed by rlwrap-0.45.2-2.el7.x86_64 perl(Config) is needed by rlwrap-0.45.2-2.el7.x86_64 perl(Data::Dumper) is needed by rlwrap-0.45.2-2.el7.x86_64 perl(Exporter) is needed by rlwrap-0.45.2-2.el7.x86_64 perl(File::Slurp) is needed by rlwrap-0.45.2-2.el7.x86_64 perl(Getopt::Std) is needed by rlwrap-0.45.2-2.el7.x86_64 perl(POSIX) is needed by rlwrap-0.45.2-2.el7.x86_64 perl(constant) is needed by rlwrap-0.45.2-2.el7.x86_64 perl(lib) is needed by rlwrap-0.45.2-2.el7.x86_64 perl(strict) is needed by rlwrap-0.45.2-2.el7.x86_64 perl(vars) is needed by rlwrap-0.45.2-2.el7.x86_64

rpm 설치 진행 중 의존성 에러 발생, 의존성에 필요한 패키지 설치

[root@2235f66166cf ~]# yum install -y perl perl-Data-Dumper perl-File-Slurp python3 [oracle@2235f66166cf ~]$ rlwrap Usage: rlwrap [options] command ... Options: -a[password prompt] --always-readline[=password prompt] -A --ansi-colour-aware -b <chars> --break-chars=<chars> -c --complete-filenames -C <name|N> --command-name=<name|N> -D <0|1|2> --history-no-dupes=<0|1|2> -e <char|''> --extra-char-after-completion=<char|''> -f <completion list> --file=<completion list> -g <regexp> --forget-matching=<regexp> -h --help -H <file> --history-filename=<file> -i --case-insensitive -I --pass-sigint-as-sigterm -l <file> --logfile=<file> -m[newline substitute] --multi-line[=newline substitute] -M <.ext> --multi-line-ext=<.ext> -n --no-warnings -N --no-children -o --one-shot -O <regexp> --only-cook=<regexp> -p[colour] --prompt-colour[=colour] -P <input> --pre-given=<input> -q <chars> --quote-characters=<chars> -r --remember -R --renice -s <N> --histsize=<N> (negative: readonly) -S <prompt> --substitute-prompt=<prompt> -t <name> --set-term-name=<name> -U --mirror-arguments -v --version -w <N> --wait-before-prompt=<N> (msec, <0 : patient mode) -W --polling -z <filter command> --filter=<filter command> ('rlwrap -z listing' writes a list of installed filters) bug reports, suggestions, updates: https://github.com/hanslub42/rlwrap

 

적용하기
[oracle@2235f66166cf ~]$ vi .bashrc alias sqlplus='rlwrap sqlplus' [oracle@2235f66166cf ~]$ source .bashrc

SQL 수행 후에 ↑방향키 누르면 수행했던 SQL을 불러 올 수 있습니다.

 

 

728x90
반응형

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.