G014-ORACLE-ASK O SQL*PLUS / 达梦DiSQL / 高斯ZSQL 命令行翻页

[TOC]

您需要知道的

  • ORACLE SQL* PLUS 工具 / 达梦数据库 DiSQL 工具 / GaussDB ZSQL 工具 设置命令行翻页操作步骤完全一致
  • 安装 ORACLE 官方使用的默认操作系统用户为 oracle
  • 安装达梦数据库官方使用的默认操作系统用户为 dmdba
  • 安装高斯数据库官方使用 ROOT 管理员,但登陆数据库切换的默认操作系统用户为 omm
  • 本篇不适合零基础,您需要有 Linux 使用经验及了解如何配置本地及在线 YUM 源
  • 您需自行下载 rlwrap-0.42.tar.gz 压缩包资源(其他版本方法一致)

1 安装 READLINE 依赖包

  • 编译配置 rlwrap 需要有 readline 包支持,通过 YUM 源安装 readline
[root@hairui ~]# yum repolist all
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
repo id             repo name                status
!henry              henry_local              enabled: 5,152
repolist: 5,152
[root@hairui ~]# yum install -y readline*

2 解压编译 RLWRAP 包

  • 解压
[root@hairui ~]# cd /soft/
[root@hairui soft]# tar -zxvf rlwrap-0.42.tar.gz 
rlwrap-0.42/
rlwrap-0.42/PLEA
rlwrap-0.42/tools/
rlwrap-0.42/tools/config.sub
rlwrap-0.42/tools/test-driver
rlwrap-0.42/tools/install-sh
rlwrap-0.42/tools/missing
rlwrap-0.42/tools/config.guess
rlwrap-0.42/tools/compile
rlwrap-0.42/tools/depcomp
rlwrap-0.42/NEWS
rlwrap-0.42/aclocal.m4
rlwrap-0.42/config.h.in
rlwrap-0.42/configure.ac
rlwrap-0.42/ChangeLog
rlwrap-0.42/completions/
rlwrap-0.42/completions/coqtop
rlwrap-0.42/completions/testclient
rlwrap-0.42/COPYING
rlwrap-0.42/src/
rlwrap-0.42/src/string_utils.c
rlwrap-0.42/src/term.c
rlwrap-0.42/src/main.c
rlwrap-0.42/src/completion.rb
rlwrap-0.42/src/pty.c
rlwrap-0.42/src/utils.c
rlwrap-0.42/src/rlwrap.h
rlwrap-0.42/src/signals.c
rlwrap-0.42/src/redblack.h
rlwrap-0.42/src/completion.c
rlwrap-0.42/src/filter.c
rlwrap-0.42/src/ptytty.c
rlwrap-0.42/src/malloc_debug.h
rlwrap-0.42/src/Makefile.am
rlwrap-0.42/src/readline.c
rlwrap-0.42/src/malloc_debug.c
rlwrap-0.42/src/Makefile.in
rlwrap-0.42/TODO
rlwrap-0.42/BUGS
rlwrap-0.42/doc/
rlwrap-0.42/doc/rlwrap.man.in
rlwrap-0.42/doc/Makefile.am
rlwrap-0.42/doc/Makefile.in
rlwrap-0.42/configure
rlwrap-0.42/Makefile.am
rlwrap-0.42/INSTALL
rlwrap-0.42/README
rlwrap-0.42/test/
rlwrap-0.42/test/testit
rlwrap-0.42/test/testclient
rlwrap-0.42/filters/
rlwrap-0.42/filters/listing
rlwrap-0.42/filters/logger
rlwrap-0.42/filters/pipeline
rlwrap-0.42/filters/RlwrapFilter.3pm
rlwrap-0.42/filters/history_format
rlwrap-0.42/filters/ftp_filter
rlwrap-0.42/filters/pipeto
rlwrap-0.42/filters/unbackspace
rlwrap-0.42/filters/Makefile.am
rlwrap-0.42/filters/null
rlwrap-0.42/filters/simple_macro
rlwrap-0.42/filters/censor_passwords
rlwrap-0.42/filters/README
rlwrap-0.42/filters/RlwrapFilter.pm
rlwrap-0.42/filters/Makefile.in
rlwrap-0.42/filters/count_in_prompt
rlwrap-0.42/filters/scrub_prompt
rlwrap-0.42/filters/template
rlwrap-0.42/filters/paint_prompt
rlwrap-0.42/Makefile.in
rlwrap-0.42/AUTHORS
  • 编译
[root@hairui soft]# cd rlwrap-0.42/
[root@hairui rlwrap-0.42]# ls
aclocal.m4  ChangeLog    configure     doc      Makefile.am  PLEA    test
AUTHORS     completions  configure.ac  filters  Makefile.in  README  TODO
BUGS        config.h.in  COPYING       INSTALL  NEWS         src     tools
# 在 README 文件里面直接复制命令 ./configure; make install 进行配置编译
[root@hairui rlwrap-0.42]# cat README 
[root@hairui rlwrap-0.42]# ./configure; make install
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make sets $(MAKE)... (cached) yes
checking whether build environment is sane... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking how to run the C preprocessor... gcc -E
checking for perl... /bin/perl
checking for strip... strip
checking for ANSI C header files... (cached) yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking libutil.h usability... no
checking libutil.h presence... no
checking for libutil.h... no
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sched.h usability... yes
checking sched.h presence... yes
checking for sched.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking for sys/wait.h... (cached) yes
checking sys/resource.h usability... yes
checking sys/resource.h presence... yes
checking for sys/resource.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking for stdint.h... (cached) yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking regex.h usability... yes
checking regex.h presence... yes
checking for regex.h... yes
checking curses.h usability... yes
checking curses.h presence... yes
checking for curses.h... yes
checking termcap.h usability... yes
checking termcap.h presence... yes
checking for termcap.h... yes
checking for term.h... yes
checking for ncurses/term.h... yes
checking argument type of tputs putc function... int
checking whether your getopt() correctly understands double colons in option string... yes
checking for an ANSI C-conforming const... yes
checking for pid_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking whether gcc needs -traditional... no
checking return type of signal handlers... void
checking for getopt_long... yes
checking for getopt_long... (cached) yes
checking for isastream... yes
checking for mkstemps... yes
checking for pselect... yes
checking for putenv... yes
checking for readlink... yes
checking for sched_yield... yes
checking for setenv... yes
checking for setitimer... yes
checking for setsid... yes
checking for setrlimit... yes
checking for sigaction... yes
checking for snprintf... yes
checking for strlcpy... no
checking for strlcat... no
checking for strnlen... yes
checking for system... yes
checking for openpty in -lutil... yes
checking for openpty... yes
checking for getpty... no
checking for grantpt... yes
checking for unlockpt... yes
checking for getpt... yes
checking for pty/tty type... checking pty.h usability... yes
checking pty.h presence... yes
checking for pty.h... yes
OPENPTY
configure: checking for pty ranges...
checking for tgetent... no
checking for tgetent in -ltinfo... yes
checking for readline in -lreadline... yes
checking for tigetnum... yes
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes
checking whether your readline headers know about rl_set_screen_size... yes
checking whether your readline library knows about rl_set_screen_size... checking for rl_set_screen_size... yes
checking whether your readline knows about rl_variable_value... yes
checking whether your readline knows about rl_readline_version... yes
Will rlwrap find command's working directory under /proc//cwd? let's see...
checking for /proc/12555/cwd/configure.ac... yes
checking whether we can find command line under //cmdline and mirror it by overwriting our own *argv... no
checking that generated files are newer than configure... done
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating filters/Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating doc/rlwrap.man
config.status: creating config.h
config.status: executing depfiles commands
Now do:
    make (or gmake)  to build rlwrap
    make check       for instructions how to test it
    make install     to install it
Making install in doc
make[1]: Entering directory `/soft/rlwrap-0.42/doc'
sed -e 's#@DATADIR@#/usr/local/share#'  rlwrap.man > rlwrap.1
make[2]: Entering directory `/soft/rlwrap-0.42/doc'
make[2]: Nothing to be done for `install-exec-am'.
 /bin/mkdir -p '/usr/local/share/man/man1'
 /bin/install -c -m 644 rlwrap.1 '/usr/local/share/man/man1'
make[2]: Leaving directory `/soft/rlwrap-0.42/doc'
make[1]: Leaving directory `/soft/rlwrap-0.42/doc'
Making install in src
make[1]: Entering directory `/soft/rlwrap-0.42/src'
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT signals.o -MD -MP -MF .deps/signals.Tpo -c -o signals.o signals.c
mv -f .deps/signals.Tpo .deps/signals.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT readline.o -MD -MP -MF .deps/readline.Tpo -c -o readline.o readline.c
mv -f .deps/readline.Tpo .deps/readline.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT pty.o -MD -MP -MF .deps/pty.Tpo -c -o pty.o pty.c
mv -f .deps/pty.Tpo .deps/pty.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT completion.o -MD -MP -MF .deps/completion.Tpo -c -o completion.o completion.c
mv -f .deps/completion.Tpo .deps/completion.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT term.o -MD -MP -MF .deps/term.Tpo -c -o term.o term.c
mv -f .deps/term.Tpo .deps/term.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT ptytty.o -MD -MP -MF .deps/ptytty.Tpo -c -o ptytty.o ptytty.c
mv -f .deps/ptytty.Tpo .deps/ptytty.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT utils.o -MD -MP -MF .deps/utils.Tpo -c -o utils.o utils.c
mv -f .deps/utils.Tpo .deps/utils.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT string_utils.o -MD -MP -MF .deps/string_utils.Tpo -c -o string_utils.o string_utils.c
mv -f .deps/string_utils.Tpo .deps/string_utils.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT malloc_debug.o -MD -MP -MF .deps/malloc_debug.Tpo -c -o malloc_debug.o malloc_debug.c
mv -f .deps/malloc_debug.Tpo .deps/malloc_debug.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT filter.o -MD -MP -MF .deps/filter.Tpo -c -o filter.o filter.c
mv -f .deps/filter.Tpo .deps/filter.Po
gcc -DDATADIR=\"/usr/local/share\"  -g -O2   -o rlwrap main.o signals.o readline.o pty.o completion.o term.o ptytty.o utils.o string_utils.o malloc_debug.o filter.o  -lutil  -lreadline -ltinfo
make[2]: Entering directory `/soft/rlwrap-0.42/src'
 /bin/mkdir -p '/usr/local/bin'
  /bin/install -c rlwrap '/usr/local/bin'
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/soft/rlwrap-0.42/src'
make[1]: Leaving directory `/soft/rlwrap-0.42/src'
Making install in filters
make[1]: Entering directory `/soft/rlwrap-0.42/filters'
make[2]: Entering directory `/soft/rlwrap-0.42/filters'
make[2]: Nothing to be done for `install-exec-am'.
 /bin/mkdir -p '/usr/local/share/man/man3'
 /bin/install -c -m 644 RlwrapFilter.3pm '/usr/local/share/man/man3'
make[2]: Leaving directory `/soft/rlwrap-0.42/filters'
make[1]: Leaving directory `/soft/rlwrap-0.42/filters'
make[1]: Entering directory `/soft/rlwrap-0.42'
make[2]: Entering directory `/soft/rlwrap-0.42'
make[2]: Nothing to be done for `install-exec-am'.
 /bin/mkdir -p '/usr/local/share/rlwrap'
 /bin/mkdir -p '/usr/local/share/rlwrap/filters'
 /bin/install -c -m 644  filters/README filters/RlwrapFilter.pm filters/RlwrapFilter.3pm filters/count_in_prompt filters/pipeto filters/logger filters/null filters/unbackspace filters/pipeline filters/ftp_filter filters/history_format filters/simple_macro filters/template filters/scrub_prompt filters/paint_prompt filters/censor_passwords filters/listing '/usr/local/share/rlwrap/filters'
 /bin/mkdir -p '/usr/local/share/rlwrap/completions'
 /bin/install -c -m 644  completions/testclient completions/coqtop '/usr/local/share/rlwrap/completions'
make  install-data-hook
make[3]: Entering directory `/soft/rlwrap-0.42'
chmod a+x /usr/local/share/rlwrap/filters/* 
make[3]: Leaving directory `/soft/rlwrap-0.42'
make[2]: Leaving directory `/soft/rlwrap-0.42'
make[1]: Leaving directory `/soft/rlwrap-0.42'

3 配置用户环境变量

  • 切换 oracle 用户 / 或切换 dmdba 用户 / 或切换 omm 用户
[root@hairui ~]# su - oracle
[root@hairui ~]# su - dmdba
[root@hairui ~]# su - omm
  • 修改对应操作系统用户的环境变量配置文件 .bash_profile
[oracle@hairui ~]$ vim .bash_profile
# 添加别名配置
alias sqlplus='rlwrap sqlplus'
[dmdba@hairui ~]$ vim .bash_profile
# 添加别名配置
alias disql='rlwrap disql'
[omm@hairui ~]$ vim .bash_profile
# 添加别名配置
alias zsql='rlwrap zsql'
  • 配置文件修改完成后执行 source 刷新,登陆 SQL 命令行实现翻页功能
source .bash_profile
sqlplus / as sysdba
disql sysdba/Dameng123
zsql SYS/Changeme_123

[End]

请使用浏览器的分享功能分享到微信等