■ EC2 amazon linux 2023にsqlplus をインストール
$ wget https://download.oracle.com/otn_software/linux/instantclient/1924000/instantclient-basiclite-linux.x64-19.24.0.0.0dbru.zip
$ wget https://download.oracle.com/otn_software/linux/instantclient/1924000/instantclient-sqlplus-linux.x64-19.24.0.0.0dbru.zip
# mkdir -p /opt/oracle
# unzip instantclient-basiclite-linux.x64-19.24.0.0.0dbru.zip -d /opt/oracle
# unzip instantclient-sqlplus-linux.x64-19.24.0.0.0dbru.zip -d /opt/oracle
# ln -s instantclient_19_24 instantclient
# vi /etc/profile.d/oracle.sh <<__EOF__
#export LD_LIBRARY_PATH=/usr/lib/oracle/19.20/client64/lib/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/oracle/instantclient:$LD_LIBRARY_PATH
export PATH=/opt/oracle/instantclient:$PATH
__EOF__
$ source /etc/profile
$ sqlplus ${USER}/${RDS_PASSWORD}@${RDS_ENDPOINT}/SID
oracle-instantclient 18.5-basic-18.5.0.0.0-3.x86_64.rpm
oracle-instantclient18.5-sqlplus-18.5.0.0.0-3.x86_64.rpm
# yum install -y libaio
# rpm -ivh oracle-instantclient18.5-basic-18.5.0.0.0-3.x86_64.rpm
# rpm -ivh oracle-instantclient18.5-sqlplus-18.5.0.0.0-3.x86_64.rpm
# ls -l /usr/lib/oracle/18.5/client64/lib 確認
# echo "/usr/lib/oracle/18.5/client64/lib" >> /etc/ld.so.conf.d/oracle.conf
# cat !$ 確認
# ldconfig
# sqlplus64
SQL*Plus: Release 18.0.0.0.0 - Production on Tue Apr 9 19:01:08 2019
Version 18.5.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Enter user-name:
[カーソルキーを使えるようにする]
# yum -y install rlwrap
# mkdir -p /usr/local/opt/rlwrap-extensions
# cd /usr/local/opt/rlwrap-extensions
# wget http://www.linuxification.at/download/rlwrap-extensions-V11-0.05.tar.gz (11gの場合)
# tar xzvf rlwrap-extensions-V11-0.05.tar.gz <-辞書
# vi /etc/profile.d/oracle.sh
alias sqlplus='rlwrap -pRed -if /usr/local/opt/rlwrap-extensions/sqlplus sqlplus'
[12g]
# wget http://www.linuxification.at/download/rlwrap-extensions-V12-0.05.tar.gz (12gの場
# tar xzvf rlwrap-extensions-V12-0.05.tar.gz <-辞書
# vi /usr/local/opt/rlwrap-extensions/sql+
R_HOME=${RLWRAP_HOME:=/usr/local/opt/rlwrap-extensions}
# cd /usr/local/bin
# ln -s /usr/local/opt/rlwrap-extensions/asm+ asm+
# ln -s /usr/local/opt/rlwrap-extensions/sql+ sql+
※ rlwap インストールには、epel リポジトリが必要。
[rocky]
# dnf config-manager --set-enabled powertools
# dnf install epel-release
[参考]
$ sqlplus user/password@192.168.1.xxx:1521/sid
$ sqlplus system/oracle@192.168.25.131:1521/arcsdbms
SQL> @calc.sql
13 ;
[sample]
$ vi calc.sql
with
CALC as (
SELECT
TO_DATE('20190405', 'yyyymmdd') - (ROWNUM - 1) as cdate
FROM ALL_CATALOG
WHERE TO_DATE('20190405', 'yyyymmdd') - (ROWNUM - 1) >= TO_DATE('20190315', 'yyyymmdd')
ORDER BY 1 desc
)
select
TO_CHAR(c.cdate, 'yyyymmdd') as cdate,
'('||SUBSTR(TO_CHAR(c.cdate, 'day','NLS_DATE_LANGUAGE=JAPANESE'),1,1)||')' as cday
from CALC c