RDS Oracle Client Install

# 1 Download Oracle Client SQL Plus

Refer:
[AWS instructor](https://docs.aws.amazon.com/ja_jp/AmazonRDS/latest/UserGuide/USER_ConnectToOracleInstance.SQLPlus.html)

[Oracle Instant Client Downloads](https://www.oracle.com/database/technologies/instant-client/downloads.html)

CentOS, so download the RPM
Instant Client for Linux x86-64
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/133516/a4bcaf2a-4dbc-75e8-7ec2-28b3bb2ed1dc.png)


# 2 Install
Upload and install

```bash
sudo yum localinstall oracle-instantclient19.19-basic-19.19.0.0.0-1.x86_64.rpm
sudo yum localinstall oracle-instantclient19.19-sqlplus-19.19.0.0.0-1.x86_64.rpm

```

```bash
[centos@cdp ~]$ sudo yum localinstall oracle-instantclient19.19-basic-19.19.0.0.0-1.x86_64.rpm
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Examining oracle-instantclient19.19-basic-19.19.0.0.0-1.x86_64.rpm: oracle-instantclient19.19-basic-19.19.0.0.0-1.x86_64
Marking oracle-instantclient19.19-basic-19.19.0.0.0-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package oracle-instantclient19.19-basic.x86_64 0:19.19.0.0.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================================================
 Package                                              Arch                        Version                             Repository                                                                  Size
=======================================================================================================================================================================================================
Installing:
 oracle-instantclient19.19-basic                      x86_64                      19.19.0.0.0-1                       /oracle-instantclient19.19-basic-19.19.0.0.0-1.x86_64                      226 M

Transaction Summary
=======================================================================================================================================================================================================
Install  1 Package

Total size: 226 M
Installed size: 226 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : oracle-instantclient19.19-basic-19.19.0.0.0-1.x86_64                                                                                                                                1/1
  Verifying  : oracle-instantclient19.19-basic-19.19.0.0.0-1.x86_64                                                                                                                                1/1

Installed:
  oracle-instantclient19.19-basic.x86_64 0:19.19.0.0.0-1

Complete!
[centos@cdp ~]$

[centos@cdp ~]$ sudo yum localinstall oracle-instantclient19.19-sqlplus-19.19.0.0.0-1.x86_64.rpm
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Examining oracle-instantclient19.19-sqlplus-19.19.0.0.0-1.x86_64.rpm: oracle-instantclient19.19-sqlplus-19.19.0.0.0-1.x86_64
Marking oracle-instantclient19.19-sqlplus-19.19.0.0.0-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package oracle-instantclient19.19-sqlplus.x86_64 0:19.19.0.0.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================================================
 Package                                               Arch                       Version                            Repository                                                                   Size
=======================================================================================================================================================================================================
Installing:
 oracle-instantclient19.19-sqlplus                     x86_64                     19.19.0.0.0-1                      /oracle-instantclient19.19-sqlplus-19.19.0.0.0-1.x86_64                     3.1 M

Transaction Summary
=======================================================================================================================================================================================================
Install  1 Package

Total size: 3.1 M
Installed size: 3.1 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : oracle-instantclient19.19-sqlplus-19.19.0.0.0-1.x86_64                                                                                                                              1/1
  Verifying  : oracle-instantclient19.19-sqlplus-19.19.0.0.0-1.x86_64                                                                                                                              1/1

Installed:
  oracle-instantclient19.19-sqlplus.x86_64 0:19.19.0.0.0-1

Complete!
[centos@cdp ~]$

```




# 3 Connect with Oracle

```bash
sqlplus 'admin@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dns_name)(PORT=1521))(CONNECT_DATA=(SID=database_name)))'

sqlplus \
admin@zzeng-*******.amazonaws.com:1521/orcl

```


#4 動作確認
```bash
CREATE TABLE my_table (
    id INT PRIMARY KEY,
    name VARCHAR2(100),
    age NUMBER
);

INSERT INTO my_table (id, name, age) VALUES (1, 'Alice', 30);
INSERT INTO my_table (id, name, age) VALUES (2, 'Bob', 25);
INSERT INTO my_table (id, name, age) VALUES (3, 'Charlie', 35);
INSERT INTO my_table (id, name, age) VALUES (4, 'David', 28);
INSERT INTO my_table (id, name, age) VALUES (5, 'Eva', 22);
INSERT INTO my_table (id, name, age) VALUES (6, 'Frank', 33);
INSERT INTO my_table (id, name, age) VALUES (7, 'Grace', 29);
INSERT INTO my_table (id, name, age) VALUES (8, 'Hannah', 24);
INSERT INTO my_table (id, name, age) VALUES (9, 'Ian', 31);
INSERT INTO my_table (id, name, age) VALUES (10, 'Julia', 27);
INSERT INTO my_table (id, name, age) VALUES (11, 'Kyle', 26);
INSERT INTO my_table (id, name, age) VALUES (12, 'Laura', 32);
INSERT INTO my_table (id, name, age) VALUES (13, 'Michael', 21);
INSERT INTO my_table (id, name, age) VALUES (14, 'Nora', 34);
INSERT INTO my_table (id, name, age) VALUES (15, 'Oscar', 29);
INSERT INTO my_table (id, name, age) VALUES (16, 'Patty', 23);
INSERT INTO my_table (id, name, age) VALUES (17, 'Quinn', 38);
INSERT INTO my_table (id, name, age) VALUES (18, 'Rachel', 36);
INSERT INTO my_table (id, name, age) VALUES (19, 'Steve', 40);
INSERT INTO my_table (id, name, age) VALUES (20, 'Tina', 21);

COMMIT;
```