Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 下 SQL*Plus 歷史命令無法使用方向鍵的解決方案

編輯:Linux 教學

問題現象

Linux 環境下運行 sqlplus,方向鍵顯示亂碼 (如 ^[[A),無法翻閱歷史命令、移動光標編輯。

解決方案:安裝 rlwrap

# 1. 下載編譯安裝
su - root
wget https://utopia.knoware.nl/~hlub/rlwrap/rlwrap-0.30.tar.gz
tar zxvf rlwrap-0.30.tar.gz
cd rlwrap-0.30
./configure && make && make install

# 2. 為 oracle 用戶配置別名
su - oracle
echo 'alias sqlplus="rlwrap sqlplus"' >> ~/.bash_profile
echo 'alias rman="rlwrap rman"' >> ~/.bash_profile

# 3. 立即生效
source ~/.bash_profile

原理說明

rlwrap (Readline Wrapper) 利用 GNU Readline 庫為不支援行編輯的命令提供歷史、補全、光標移動等功能,透過 alias 透明包裝 sqlplus/rman。

驗證

sqlplus / as sysdba
# 現在 ↑ ↓ 可翻歷史,← → 可移動光標編輯

替代方案

  • 使用 sqlcl (Oracle SQLcl) 現代命令列工具,內建 Readline 支援
  • 配置 .sqlplusrc 設定 SET LINESIZE 200 PAGESIZE 1000 等優化顯示
Copyright © Windows教程網 All Rights Reserved