Oracle Database 19c Installation on Windows

Jared Bach
Geek Culture
Published in
21 min readSep 21, 2021

Today we are going to be installing Oracle Database 19c on Windows 2019 Server in OCI. If you do not already have a working Windows VM in OCI, first complete the steps in this blog that I also wrote. If you are using the same VM as me in OCI, you should not have to worry about checking any of the prerequisites — this should already be taken care of. Nevertheless, here are the Oracle Database 19c system prerequisites.

  • Minimum 2 GB free RAM
  • 10 GB of empty space on Hard Disk Drive
  • A processor based on either Intel EM64T or AMD64 architecture
  • Display card with minimum resolution of 1024x768 pixels

For more details on prerequisites, check-out this blog post by Manish Sharma. He does a good job explaining this and the installation process in more depth than I do. In fact, I used his blogpost to guide me through the Oracle Database 19c installation and configuration process myself. If you have not already done so, log-into your Windows instance’s GUI. Your screen should look like this.

Download Oracle Database 19c

Open-up your Brave browser that we downloaded in the previous blog and navigate to this website. When you arrive at this webpage, you are going to want to download the 19.3 zip file for Microsoft Windows x86 (64-bit), like I have circled in red below.

Before the download can commence, you will be prompted to log into your Oracle SSO account. After successfully logging-in, you will be asked where you want to save the zip file. Make a mental note of wherever this zip file is saved. It should have been saved, by default, in your Downloads folder. If you open your File Explorer and navigate to the Downloads folder, you should see the zip file there. Your File Explorer should look like this.

Create an Oracle database home directory

We do not want to extract this zip file inside of our Downloads folder. Instead, we are going to need to move this zip file into a new directory. This new directory that we will now create will be our Oracle home directory. First we are going to want to navigate to our C: drive folder. Double-click on the address bar where it says > This PC > Downloads > in the File Explorer. I have where you need to double-click circled in red below.

Then, copy and paste this command in the address bar.

C:\

Your File Explorer should now look like this.

Then, hit enter. This will take you to your C: drive folder. Your File Explorer should now look like this.

Inside the C: drive folder, create a new folder with the following name.

App

You can create a new folder by right-clicking anywhere inside of the File Explorer. A right-click menu will pop-up that looks like this.

Click “New” and then click “Folder.” You should then be able to rename the folder. After you create this folder, double-click on the App folder to open it. Your File Explorer should now look like this. This is where we are going to be building-out our Oracle home directory

Extract the zip file and finalize the Oracle home directory

Next, we are going to navigate back to our Downloads folder. Your File Explorer should look like this.

Right-click on the zip file and select the “Copy” button in the right-click pop-up menu. Now, navigate back to the App folder that we just created in our C: directory. Paste the zip file into the App folder. Once this zip file has been pasted here, we are now ready to extract the zip file. We can extract the zip file by right-clicking on the zip file and then by selecting the “Extract All…” option in the right-click menu. A new window should pop-up that looks like this.

Where it says “Files will be extracted to this folder:”, we are going to change the extraction location to this.

C:\App\db_home

Copy and paste the above directory path into this address bar. The window should now look like this.

When you are ready, click “Extract.” Be patient — this will take a hot second. Once this is finally completed, you should see a new folder named db_home inside the App folder that we created in the previous step. Your App folder should look like this.

Install and configure Oracle Database 19c

Before beginning, make sure that you are logged into Windows with a user that has administrative privileges. I am logged-in as an administrative user, so I am good to go. Let’s now go into the db_home folder that we just created. Find the application file named “setup.exe.” I have the file circled below.

Right-click on this file and select the “Run as administrator” option in the right-click menu. If you get a pop-up that looks like the one below, click “Yes.”

Click “Yes”

A GUI installer window for Oracle Database 19c should now pop-up on your screen. Let’s run through the installation process.

Step 1: Configuration Options

Select the “Create and configure a single instance database” option and then click “Next.”

Click “Next”

Step 2: System Class

Select the “Desktop class” option and then click “Next.”

Click “Next”

Step 3: Oracle Home User

Select the “Create New Windows User” and for the username, input oracle. Keep your password somewhere safe. Click “Next.”

Click “Next”

Step 4: Typical Installation

Given that our new window’s user is “oracle,” the values in this window should look like this.

  • Oracle base: C:\App\oracle
  • Software location: C:\App\db_home
  • Database file location: C:\App\oracle\oradata
  • Database edition: Enterprise Edition
  • Character set: Unicode (AL32UTF8)
  • Global database name: orcl
  • Password: enter a password here. Keep your password somewhere safe.
  • Create as Container Database: make sure this box is checked
  • Pluggable database name: orclpdb

Your window should now look like this. Click “Next.”

Click “Next”

Step 5: Prerequisite Checks

Click “Next”

Step 6: Summary

If you wish to, you can save the response file by clicking the “Save Response File” button inside the GUI. I saved mine to my Desktop. Then, when you are ready, click “Install.”

Click “Install

Step 7: Install Product

Be patient — this takes a hot second.

Step 8 Finish

The installation is now complete.

Click “Close”

We have now successfully installed Oracle Database 19c on our Windows VM. Let’s start-up the database and log-in to SQL Plus. We can do this using Windows PowerShell.

Starting-up the database and opening the container

Click on the start menu in the bottom left-hand corner of your screen. Then right-click on the icon under “Windows Server” that says Windows PowerShell, like I have circled below in red.

After right-clicking on “Windows PowerShell,” a menu will pop-up. Under “Tasks” on the pop-up menu, select “Run as Administrator,” like I have circled below in red.

If you get a pop-up that looks like the one below, click “Yes.”

Click “Yes”

Your Windows PowerShell should now look like this.

Before we log-in to SQL Plus, lets set-up the Oracle SID variable in our environment with the following command.

set ORACLE_SID=orcl

Next, input the following command to log-in to SQL Plus as SYS DBA.

sqlplus "/ AS SYSDBA"

Once inside SQL Plus, run this command to startup the database.

STARTUP;

Run the command below to open-up our container database.

ALTER PLUGGABLE DATABASE ALL OPEN;

Execute the following command in SQL to view the open status of our container databases.

SELECT name, con_id, open_mode FROM v$pdbs;

Your output should look something like this.

As you can see, the PDB base is ORCLPDB. Additionally, we can see that ORCLPDB is open and has read and write privileges. This is because we altered the database with the previous command and opened the containers. Next, run the following query.

SELECT CON_ID, NAME, OPEN_MODE FROM V$CONTAINERS;

Your PowerShell should look like this.

It looks like everything is running. We are not done yet, however. We need to check to see that our connection to the database works. We can do this with SQL Developer.

Type exit in your terminal and press enter to exit SQL Plus and to return to the normal terminal.

Installing SQL Developer on Windows

Step 1: Installing JDK

Before we install SQL Developer, we need to make sure that we have the correct version of Java JDK installed. For SQL Developer to work properly, we need either JDK 8 or 11. You can check whether you already have Java installed by inputing the following command into your command prompt.

java -version

You can open your command prompt by searching for it in the start menu in the bottom left-hand corner of your desktop.

If your command returns a result that resembles this, you most likely do not have Java installed on your computer.

Navigate to this page to download JDK 8. Download jdk1.8.0_77.zip.

Make a mental note of wherever this zip file is saved. It should have been saved, by default, in your Downloads folder. If you open your File Explorer and navigate to the Downloads folder, you should see the zip file there. Your File Explorer should look like this.

We can extract the zip file by right-clicking on the zip file and then by selecting the “Extract All…” option in the right-click menu. A new window should pop-up that looks like this.

Where it says “Files will be extracted to this folder:”, we are going to change the extraction location to this.

C:\Program Files\Java

Copy and paste the above directory path into this address bar. The window should now look like this.

When you are ready, click “Extract.” If a window pops-up that looks like this, click “Continue.”

Click “Continue”

Once this is finally completed, we are now going to navigate to where Java is installed on our computer using the File Explorer. Double-click on the address bar where it says > Quick Access > in the File Explorer. I have where you need to double-click circled in red below.

Then, copy and paste this command in the address bar.

C:\Program Files\Java

Your File Explorer should now look like this.

Then, hit enter. This will take you to your Java installation location. Your File Explorer should now look like this.

Double-click on the jdk1.8.0_77 folder. Your File Explorer should look like this. Circled in red is the bin folder. Double-click on this.

Your File Explorer should now look like this.

This is where all of your important Java related executable files are stored. We now want to set this bin folder as our environment variable, so that we can run all of the related Java commands inside the command prompt and the Windows PowerShell. Double-click on the address bar, circled in red above. Make a note of the path. The path should be as follows.

C:\Program Files\Java\jdk1.8.0_77\bin

We are going to add this directory to our path. First, click on the start menu in the bottom left-hand corner of your screen. Then, open your settings app by clicking on the gear icon, circled in red.

Your screen should now look like this. Click-on “System.”

Your screen should now looks like this.

Inside the “Find a setting” search bar, search for the following.

Edit the system environment variables

Select the only option below.

A new window should pop-up that now looks like this. Click on “Environment Variables,” which I have circled in red below.

A new window should pop-up that now looks like this. Click on “Path” under “System variables.” Then, click “edit.”

A new window should pop-up that now looks like this. Click the “New” button and paste the Java/bin path here.

Your screen should now look like this. Click “OK.”

We are now going to set our JAVA_HOME environment variable. In your Environment Variables screen, click the “New” button, circled in red below.

A new window should pop-up that looks like this.

Set “Variable name” as follows.

JAVA_HOME

Set the “Variable value” as follows.

C:\Program Files\Java\jdk1.8.0_77

Note that we are not including the bin in out path here. The window should now look like this. Click “OK.”

Let’s now also set the ORACLE_HOME variable and add it to our path. In your Environment Variables screen, click the “New” button, circled in red below.

A new window should pop-up that looks like this.

Set “Variable name” as follows.

ORACLE_HOME

Set the “Variable value” as follows.

C:\App\db_home

The window should now look like this. Click “OK.”

Awesome — Let’s now add the ORACLE_HOME to our path. Click on “Path” under “System variables.” Then, click “edit.”

A new window should pop-up that now looks like this. Click the “New” button and paste the ORACLE_HOME path here.

Your screen should now look like this. Click “OK.”

Again, the ORACLE_HOME path is as follows.

C:\App\db_home

Lastly, while we are here, let’s also set the ORACLE_SID variable. If you recall, we had to manually input this into the PowerShell earlier before we opened our database and SQL Plus. Let’s also add this variable here, so that we do not need to set this variable each time we would like to open a new SQL Plus session. In your Environment Variables screen, click the “New” button, circled in red below.

A new window should pop-up that looks like this.

Set “Variable name” as follows.

ORACLE_SID

Set the “Variable value” as follows.

orcl

Note that we are not including the bin in out path here. The window should now look like this. Click “OK.”

Finally, click “OK” in the Environment Variables window, as circled in red below.

Click “OK” in the System Properties window, as circled in red below.

We are once again going to check to see if we installed Java correctly by inputing the following command into our command prompt.

java -version

You can open your command prompt by searching for it in the start menu in the bottom left-hand corner of your desktop.

If your command returns a result that resembles the one below — congratulations, you have successfully installed Java on your computer. Let us now move onto installing SQL Developer.

Step 2: Installing SQL Developer

We now need to install SQL Developer. To install SQL Developer, navigate to this page and download the Windows 32-bit/64-bit file. Before the download can commence, you will be prompted to log into your Oracle SSO account. Make a mental note of where this zip file was saved. It should have been saved, by default, in your downloads folder.

Open your File Explorer and navigate to the Downloads folder. You should see the zip file there. Your File Explorer should look like this.

We can extract the zip file by right-clicking on the zip file and then by selecting the “Extract All…” option in the right-click menu. A new window should pop-up that looks like this.

When you are ready, click “Extract.” You can extract SQL Developer where ever you would like on your computer. For the purposes of this blog, I kept it in my downloads folder. Your File Explorer should now look like this. Double-click on the sqldeveloper-21.2.1.204.1703-no-jre folder.

Your File Explorer should now look like this. Double-click on the sqldeveloper folder.

Once you are inside the sqldeveloper folder, locate the sqldeveloper application, which I have circled in red below. After you locate it, double click on the application.

If you receive this message, check the “Skip This Message Next Time” and select “Yes.”

If this window pops-up, press “No.”

Oracle SQL Developer should now have successfully loaded and opened. Your screen should look like this. Minimize SQL Developer for now. We will be coming back to this.

Let’s now connect to a sample database.

Accessing a sample dataset

We are now almost done. The final step in this installation is testing our connection to a database in Oracle 19c. To test our connection, we are going to tap into a sample dataset that comes with Oracle Database 19c: the HR dataset. We first need to unlock the sample HR user for this database.

Follow the steps below to do this. Run the following command in your command prompt to log-in to SQL Plus as a SYS user.

sqlplus "/ AS SYSDBA"

Step 1: Find PDB name

Execute the following command in SQL.

SELECT name, con_id, open_mode FROM v$pdbs;

Your output should look something like this.

The PDB base is ORCLPDB. Additionally, we can see that ORCLPDB is mounted but it does not have read and write privileges — yet. We are going to fix this.

2. Update tnsnames.ora

The tnsnames.ora file contains client side network configuration parameters. Execute the line of code below in a new terminal tab, outside of SQL Plus. This will bring you to the location where your tnsnames.ora file is located, or should be located. If there is no tnsnames.ora file in this location — do not fret. We are going to create one. Before we can edit and/or create the tnsnames.ora file, we first need to enable text editing capabilities in PowerShell. We can do this by installing nano with choco.

First we need to install choco as an administrator. Open a PowerShell as an administrator. Then, install choco with the following command.

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Once the installation is complete, your PowerShell should look like this.

Next, we need to instal vim. We can do this with the following command.

choco install vim

Once the installation is complete, your PowerShell should look like this.

Let’s now change our directory with the following command. This is where our tnsnames.ora file is located.

chdir C:\App\db_home\network\admin

Let’s view the contents of this directory with the ls command. Your PowerShell should look like this.

To edit the tnsnames.ora file, run the line of code below.

 vim tnsnames.ora

Your PowerShell should now look like this.

Press Shift+G to navigate to the bottom of the document. Press the letter “i” on your keyboard to begin editing the document. Put the following text at the bottom of the document. I was having issues pasting the text, so you might need to write it out manually.

ORCLPDB = 
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpdb)
)
)

Your PowerShell should now look like this.

Once you complete this task, hit the ESC button, scroll down to the bottom of the document and type the following text. Then, hit enter.

:wq

This sequence will save the file and exit the editor.

3. Update listener.ora

The listerner.ora file contains server side network configuration parameters. To create and configure the listener.ora file, run the line of code below inside of the directory that we were just working out of.

vim listener.ora

Your PowerShell should now look like this.

Press the letter “i” on your keyboard to begin editing the document. Navigate to where the red arrow in the image above is pointing to on the document. Start a new line and input the following text here. I was having issues pasting the text, so you might need to write it out manually.

(SID_DESC = 
(GLOBAL_DBNAME = orclpdb_DGMGRL)
(ORACLE_HOME = C:\App\db_home)
(SID_NAME = orcl)
(ENVS="TNS_ADMIN=C:\App\db_home")
)

Your PowerShell should now look like this.

Once you complete this task, hit the ESC button, scroll down to the bottom of the document and type the following text. Then, hit enter.

:wq

This sequence will save the file and exit the editor. Stop and then start the listener with this command

lsnrctl stop
lsnrctl start

4. Open ORCLPDB

We now want to connect to ORCLPDB. Navigate back to your command prompt session that had SQL Plus open. If you need to re-open a terminal with SQL Plus, run this command.

sqlplus "/ AS SYSDBA"

Your command prompt should look like this.

Run the command below to open-up our container database.

ALTER PLUGGABLE DATABASE ALL OPEN;

5. Connect to container ORCLPDB

Run the command below to connect to ORCLPDB.

ALTER SESSION SET container=ORCLPDB;

6. Unlock HR schema

Finally, we can unlock the HR schema with the command below.

ALTER USER HR IDENTIFIED BY HR ACCOUNT UNLOCK;

7. Checking the tnsnames.ora configuration

In a new PowerShell outside of SQL Plus in the command prompt, change directories by executing the command below.

chdir C:\App\db_home\bin

Once you are in this directory, execute the command below to check that the tnsnames.ora file is configured correctly.

./tnsping ORCLPDB

If it is, then your output should look like this.

Let’s move onto the next step, where we will finally connect to the HR dataset.

Finalize the HR dataset connection

Next, we will need to run the hr_main.sql file to create all the objects and load the data. The following steps will provide and a summary of this installation process.

Run this command in SQL PLUS inside your command prompt.

@?/demo/schema/human_resources/hr_main.sql

Follow the prompts on the screen. Use the criteria below to guide you.

  1. Enter hr here. This is for the user HR. This is what we will use to access the database.
  2. Enter an appropriate tablespace, for example, users as the default tablespace for HR.
  3. Enter temp as the temporary tablespace for HR
  4. Enter the directory path for your log directory, for example:
C:\App\db_home\demo\schema\log

After script hr_main.sql runs successfully and schema HR is installed, you are connected as user HR. To verify that the schema was created, use the following command.

SELECT table_name FROM user_tables;

You should have gotten a result that looked like this.

We are onto something. Let’s test the connection in SQL Developer.

Accessing the HR database in SQL Developer

Open up SQL Developer on your local virtual machine. Once you are inside SQL Developer, select the “+” button under “Connections”, circled in red below.

A window will pop-up that looks like this.

Fill it out with the following criteria:

  • Name: HR
  • Username: hr
  • Password: hr
  • Service name: check this box and put ORCLPDB

The window should now look like this.

When you are ready, click “Test” — the moment of truth. You will know if it was successful if it says “Success” in the bottom left hand corner next to “Status: ”. Once the test is successful, click the “Save” button and then click “Connect.” If you are prompted for a password again, enter hr.

Your screen should now look like this.

Let’s run a quick query to see our database in-action. Let’s see how many employees there are in the database with the following SQL command.

select count(*) from employees;

I got 107 — it worked.

Starting the database after a computer reboot

One last note — if you reboot your computer you are going to need to follow the steps below to get your database up-and-running again. First, start the listener with the command below.

lsnrctl start

We now need to log back into SQL Plus. Use the command below to log back into SQL Plus.

sqlplus "/ AS SYSDBA"

Run this command to startup the database.

STARTUP;

Run the command below to open-up the container database, if it is not already open. Note: the “save state” segment of this code will make it so that you do not have to open-up your pluggable database every time your computer restarts.

ALTER PLUGGABLE DATABASE ALL OPEN; 
ALTER PLUGGABLE DATABASE ALL SAVE STATE;

Run the command below to connect to ORCLPDB, if you are not already connected to it.

ALTER SESSION SET container=ORCLPDB;

Enjoy your database.

--

--

Jared Bach
Geek Culture

GenZ business techie 👨🏻‍💻📉 lover of dogs and hummus 🇮🇱