Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
66 views

Configuring The Linux System For Oracle

The document provides instructions for installing VirtualBox and configuring a Linux system for Oracle. It involves the following steps: 1. Downloading and installing VirtualBox from its website. 2. Configuring a Linux virtual machine in VirtualBox, including allocating RAM, disk space, and network settings. 3. Installing Oracle Linux in the virtual machine and completing post-installation procedures like configuring YUM and installing grid to prepare the system for Oracle database installation. 4. Checking the Linux system meets minimum requirements for an Oracle installation like 4GB RAM, 120GB disk space, and required partitions before deploying Oracle.

Uploaded by

Deepika Baral
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Configuring The Linux System For Oracle

The document provides instructions for installing VirtualBox and configuring a Linux system for Oracle. It involves the following steps: 1. Downloading and installing VirtualBox from its website. 2. Configuring a Linux virtual machine in VirtualBox, including allocating RAM, disk space, and network settings. 3. Installing Oracle Linux in the virtual machine and completing post-installation procedures like configuring YUM and installing grid to prepare the system for Oracle database installation. 4. Checking the Linux system meets minimum requirements for an Oracle installation like 4GB RAM, 120GB disk space, and required partitions before deploying Oracle.

Uploaded by

Deepika Baral
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 87

Installing Virtual box

Step - 1 Firstly, you need to download Virtual Box in order to install the Oracle for Linux. For
downloading the software, go to https:// www.virtualbox.com

Step -2 Then after directing on virtual box page, click on download virtual box for windows.

Step -3 Choosing your current Operating System to download and use appropriately.
Step -4 Then save the installation file to your folder destination
Step -5 Now install the virtual you just downloaded from the site. This will start the installation for
Virtual Box.
Step -6 A window like above picture will appear. Then click on Next continuously to Install the
VirtualBox.
Step -7 After successfully installing the virtual box, check if virtual box has been installed or not. If
yes, any operating system is ready to install in virtual box.

A. Installing PuTTy
Go to the link below to download the software. https://www.chiark.greenend.org.uk/~sgtatham/putty/
Step 1: Choose the putty version and download the setup file in a folder.

Step 2: Run the downloaded setup file and click on next until the software is installed. You can also
change the default location of file that is going to be installed.
Step 3: After completing the installation, Open the PuTTy to check whether it’s working or not.

B. Configuring the Linux System for Oracle


Introduction
Firstly, we have to install and configure Linux to run Oracle on Linux. Oracle needs sufficient
resources like memory, disk space, tuning and other requirements. Once the proper installation of Linux
is completed only then the Oracle can be deployed or installed on the Linux. After the completion of
Oracle Installation, some specific choices can be made in Oracle Configuration to optimize the
performance on Linux.

Preinstallation Procedures for Linux


There are lists of steps that are required to configure the Linux System for Oracle. These steps involve
configuring yum, setting up parameter for kernel and also installing grid.
Configuring the Linux have to be done carefully specially the most important part among these is to
configure the Linux Filesystem. If any mistake is done or any changes to the system is needed after the
partitions then the operating system must be reinstalled. Since this is not acceptable in real time product
environment.
Though Other important components must be configured as part of Operating system, but these
components like tuneable and configuration parameters, networking can always be updated or changed
without reinstalling the Operating System.
Check and verify the minimum requirement before the installation of Linux and Oracle. These
requirements are very important for proper installation and configuration of Oracle Database Server.

Minimum Requirement
Some minimum requirements must be fulfilled for successful installation and configuration of Oracle
Database Server. If the requirement is not met then the system must be reinstalled or your hardware
must be upgraded.

 4GB of RAM: It is necessary to operate and function properly for which 3GB of RAM is the
minimum requirement of Oracle 11G. For better and fast operations, you could have more RAM
than this or I prefer minimum of 4GB of RAM.

 120GB of Hard Disk: For installing Oracle, 80GB hard disk is the minimum requirement of 11G to
work efficiently. I have given 120GB hard disk as per requirement.

 20GB of / (root): It can be called as top-level directory. I have given 20GB of space to root.

 20GB of /home: Since it contains all the files and folders of desktop, I have given 20GB of space
as home directory. If the home directory is not partitioned then the files will use the space of root
directory instead.

 /tmp must have at least 400MB of space: if /tmp partition is created then the partition must be at
least 400 MB in size. Temporary partition needs huge space so that the installation can be
performed smoothly. I have given 20 GB space for temporary partition.

 /boot must have at least 200MB of space: This partition uses space when the server is starting up.
200MB can be enough for boot partition.

 5GB of swap space: Since swap space is set two times the amount of RAM whereas our RAM is
determined as 4GB. For the systems that have more than 2GB of RAM, the amount of swap space
can be one or two time the amount of RAM. The more RAM you have, it is less likely to use the
swap space. Even though swapping has advantages, it has also disadvantaged. I have given 10GB
as swap space while configuring.

 Oracle file space: At least 1.5CB of space must be allocated for the most basic Oracle installation.
The amount size varies on the components you have chosen to install.

 Oracle data files: You must have at least 2GB of space for basic sample database such as hr, sales,
superstore etc. This space can either be on a filesystem, or on an Oracle ASM (Automatic Storage
Management) disk group.

Choosing Linux Components


While planning the installation of operating system, right Linux components should be chosen. It is
easier to configure required components during initial installation. As for Oracle 11G for Linux, the
following Oracle Linux 6.7 is only the Operating System that supports the Oracle 11G.
Oracle 11G Release

 Oracle Linux 6.7


Firstly, it is necessary to install development packages such as yum and grid installation. You would
also configure the Linux Kernel before installing the Oracle and creating a database. Following
packages are recommended while installation.

Oracle Linux 6.7 Packages


Following packages are recommended after the default packages are installed.

 Development tool: It includes configuration of yum and installation of grid.


 Kernel Development: This is not necessarily required for installing Oracle but it may be
required if you ever update the Linux Kernel.
The installation will complete correctly, if you have met the minimum requirement. If the minimum
required software packages are not installed on your system then the part of installation will fail as a
result.

Installation of Linux
Step 1: Firstly, Open the Oracle Virtual Box and Click on create to install the Oracle Linux in
VirtualBox.

Step 2: A dialog box will appear. Here you’ll have to give the name of OS and choose the version of
OS.
Step 3: Then the RAM dialog box will appear. Here a user has to allocate the RAM for Virtual Box. I
have allocated 4GB as RAM for the OS.
Step 4: After clicking on Next, a virtual hard disk option will appear. You will also need to allocate the
file location and size of the virtual hard disk from your actual hard disk. I have allocated 200GB as the
hard disk for this operating system.

Step 5: Your virtual operating system is set and


ready to work. Now before installing the Oracle
Linux, you’ll have to enable nework adapter and
select host only adapter on your network settings
that can be found on the settings button.
Step 6: After setting the network adapter, click on
storage setting and choose the disk image of Oracle linux to install the OS.

Step 7: Now Start the virtual machine to install the Operating System. After starting the machine a
screen will apeear which will say a disk is found. Choose skip for skipping media test and directly
starting the installation.
Step 8: Click on Next and select the English language. Then select the basic storage devices and discard
all the data.

Step 9: Then, Hostname and time zone are left at it is


(default).
Step 10: Next, Oracle will ask password for the root account. Enter the password and click on next.
Then, choose create custom layout on the next step.

Step 11: Then create multiple disks as follow and click on next and select Write changes to disk. This
will format and create filesystem or disks.

Step 12: After writing changes a screen will appear, click on next and a list of server name will appear.
Select the basic server and customize now button to configure the server.
Step 13: Next a screen will appear, select on desktops and the following features. (desktop, desktop
debugging, desktop platform, general purpose desktop, graphical administrative tools, kde desktop,
legacy x windows, x windows system.). Then click on next to start the installation process.
Step 14: After completing the installation, reboot of the OS will be needed. Then a screen will appear
saying welcome. Click on Forward and agree the agreements to license information. And also, do not
register your system in any case.

Step 15: After clicking on next, a create User Screen will appear. Click on Next with no information
given. Also click the next button on the date and time dialog box with no changes.

Step 16: Enable K-dump and click on finish to finalize the installation.
Step 17: Reboot your OS and check the Ip address by typing ifconfig in Terminal to successfully set up
the OS.

Post-Installation Procedures
After the installation of Linux Operating System, there are list of steps that must be done in order to
install Oracle 11G. These steps consist of configuration of yum, installation of grid, configuration of
kernel and also consists of adding user and group account on Oracle. It also includes creating
directories for the files of Oracle and its database files. These above steps are necessary to install the
Oracle Database 11 G Server.
Configuration of YUM
YUM (Yellowdog Update Modified) is a command-line that is open source and also graphical based
package management tool for RPM (RedHat Package Manager) on Linux Systems. It allows
administrator of system and also user of system to easily install, remove, update and search on software
packages of system.
To install yum, firstly you have to install required rpms. For installing RPMs, you’ll need to insert
Operating System DVD into the DVD-ROM. After successfully inserting the DVD you’ll need to make
a directory called stage. Then the files of the CD is copied to the directory we just made and then you’ll
have to install python-deltarpm and also create repository to successfully install RPMs
Moreover, you’ll need to edit the repo called packages. Repo where you’ll add your server name,
baseurl and other important factors. The following are the steps to install RPM’s in the system.

 Insert RHEL/CentOS DVD into the DVD-ROM

 mkdir -p /stage/Disk1on either PuTTy or terminal


 cp -r /media/RH<TAB>/* /stage/Disk1

 cd /stage/Disk1/Packages
 rpm -ivh createrepo<TAB> deltarpm<TAB> python-deltarpm<TAB>

 createrepo /stage/Disk1/Packages

 cd /etc/yum.repos.d
 vi packages.repo
[server]
name=server's packages
baseurl=file:///stage/Disk1/Packages
enabled=1
gpgcheck=0

After successfully installing required RPM’s you are ready to configure the YUM. To install YUM
you’ll need to switch as a root user. You’ll need to run the following codes to successfully configure
the YUM.

 yum -y install binutils-2*x86_64*


 yum -y install glibc-2*x86_64* nss-softokn-freebl-3*x86_64*
 yum -y install glibc-2*i686* nss-softokn-freebl-3*i686*
 yum -y install compat-libstdc++-33*x86_64*
 yum -y install glibc-common-2*x86_64*
 yum -y install glibc-devel-2*x86_64*
 yum -y install glibc-devel-2*i686*
 yum -y install glibc-headers-2*x86_64*
 yum -y install elfutils-libelf-0*x86_64*
 yum -y install elfutils-libelf-devel-0*x86_64*
 yum -y install gcc-4*x86_64*
 yum -y install gcc-c++-4*x86_64*
 yum -y install ksh-*x86_64*
 yum -y install libaio-0*x86_64*
 yum -y install libaio-devel-0*x86_64*
 yum -y install libaio-0*i686*
 yum -y install libaio-devel-0*i686*
 yum -y install libgcc-4*x86_64*
 yum -y install libgcc-4*i686*
 yum -y install libstdc++-4*x86_64*
 yum -y install libstdc++-4*i686*
 yum -y install libstdc++-devel-4*x86_64*
 yum -y install make-3.81*x86_64*
 yum -y install numactl-devel-2*x86_64*
 yum -y install sysstat-9*x86_64*
 yum -y install compat-libstdc++-33*i686*
 yum -y install compat-libcap*

After successfully installing all the YUM packages, you’ll need to check whether yum is correctly
configured or not. To check the yum, you can install firefox or any other browser to make sure that yum
is correctly installed.
Configuring Kernel Parameters
In order to make Oracle Database Server work and function, some default resources of operating
system must be configured. These resources by default are set too low for the Oracle Database Server
11G to start and run properly but the Linux Operating system allows these parameters to dynamically
change without any reboot.
The parameters that are needed to be modified and configured are semaphore, shared meomory, max
number of open files and the port range that requires IP’s. Following should be added and configured to
configure to Kernel.

 vi /etc/sysctl.conf

kernel.shmall = 2097152

kernel.shmmax = 982431744

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

fs.file-max = 6815744

fs.aio-max-nr = 1048576

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576
 sysctl –p

Specify Resource Limitations


To Install Oracle on the OS, it is important to configure the limitation of resource so that the system is
secure. Following script on end of configuration file will set limitation on the resource of the system.

 vi /etc/security/limits.conf

oracle soft nproc 2047


oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
Disabling SeLinux (Security Linux) and Firewall
Firewall is one of the important factors that can fail the installation of Oracle. It is necessary to disable
the firewall on the start-up of the Operating system to install the oracle. The following code will disable
the firewall on permanent basis.

 setenforce 0

 vi /etc/sysconfig/selinux
SELINUX=disabled

 iptables -F
 service iptables save
 chkconfig iptables off

Adding User and Groups


Even to Install Oracle on the Operating System, it is required to create Oracle and Grid user account.
To create users and groups the user must sign into root account where the following script can be
added. Following is the step to add user and group. This following script sets password for the users.

 groupadd asmadmin
 groupadd asmdba
 groupadd asmoper
 groupadd oinstall
 groupadd dba
 groupadd oper
 useradd -g oinstall -G dba,asmadmin,asmdba,asmoper -d /home/grid grid
 useradd -g oinstall -G dba,oper,asmdba -d /home/oracle oracle
 passwd grid
 passwd oracle

Creating Necessary Directories


To install Oracle 11g we have to create three directories. These directories have different purpose. The
three directories are created for grid and oracle.]

 Oracle Base: Used as the main directory for the Oracle tree
 Oracle Inventory: This is used as the location for Oracle Installer.
 Oracle Home: Here in this directory a software version is installed and is also a subdirectory of
Oracle Base.
For the data files of Oracle, the directory naming structure follows the convention of:

 Mount_point/app/oracle

The typical mount point for Oracle data files can be /u01, /u02, /u03…. And /opt/oracle for the Oracle
home directory. The path for Oracle Inventory directory is oracle_base/oraInventory.

Oracle Directory Structure Example


Oracle 11g will have a directory structure like below:

/opt/oracle Oracle Base


/opt/oracle/oraInventory Directory for Oracle Inventory
/opt/oracle/product/11.2.0/db l Oracle Home Directory
/u01/app/oracle/oradata/SID Location of Oracle data files for a SID name
SID

Setting Up Oracle Environment


Oracle 11g does not require any Oracle Environment variables compare to the previous version of
Oracle.
Oracle Permissions to Directory
The directory that are mentioned above should be owned by the user that has permission 755 with the
group of oinstall. To accomplish this run the following code:
 mkdir -p /u01/app/oracle
 chown oracle:oinstall /u01/app/oracle
 chmod -r 775 /u01

After the permission switch the root user to oracle and add the following code to bash_profile of user
Oracle.

 ORACLE_HOSTNAME=localhost.localdomain; export ORACLE_HOSTNAME


 ORACLE_SID=optimization_superstore; export ORACLE_SID
 ORACLE_UNQNAME= optimization_superstore; export ORACLE_UNQNAME
 JAVA_HOME=/usr/local/java; export JAVA_HOME
 ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
 ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
 ORACLE_TERM=xterm; export ORACLE_TERM
 NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT
 TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
 ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
 PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin
 PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
 PATH=${PATH}:/u01/app/common/oracle/bin
 export PATH
 LD_LIBRARY_PATH=$ORACLE_HOME/lib
 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
 export LD_LIBRARY_PATH
 CLASSPATH=$ORACLE_HOME/JRE
 CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
 CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
 CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
 export CLASSPATH
 THREADS_FLAG=native; export THREADS_FLAG
 export TEMP=/tmp
 export TMPDIR=/tmp
 umask 022

After editing this document, switch the user again to grid and add the following code to bash_profile of
the grid user.

 ORACLE_HOSTNAME=localhost.localdomain; export ORACLE_HOSTNAME


 ORACLE_SID=+ASM; export ORACLE_SID
 JAVA_HOME=/usr/local/java; export JAVA_HOME
 ORACLE_BASE=/u01/app/grid; export ORACLE_BASE
 ORACLE_HOME=/u01/app/11.2.0/grid; export ORACLE_HOME
 ORACLE_TERM=xterm; export ORACLE_TERM
 NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT
 TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
 ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
 PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin
 PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
 PATH=${PATH}:/u01/app/common/oracle/bin
 export PATH
 LD_LIBRARY_PATH=$ORACLE_HOME/lib
 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
 export LD_LIBRARY_PATH
 CLASSPATH=$ORACLE_HOME/JRE
 CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
 CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
 CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
 export CLASSPATH
 THREADS_FLAG=native; export THREADS_FLAG
 export TEMP=/tmp
 export TMPDIR=/tmp
 umask 022

 umask 022
This is the command that sets the default file creation mask. The mask 022 will create files with rw-
r--r—permissions or 644. This command is set on both the bash_profile of user and grid.

 export TEMP=/tmp
export TMPDIR=/tmp
These above variables TEMP and TMPDIR should be set when you do not have sufficient space in
the directories. These above variables are added in both the bash_profile of oracle and grid.

 ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE


ORACLE_SID=optimization_superstore; export ORACLE_SID
The final stage is to set variables for ORACLE_BASE and ORACLE_SID. These are both set in grid
and oracle user.
Creating Disks/Partition
It is necessary to partition the disk so that the data are saved correctly in the disk. Even ASM require
disks to be partitioned so that ASM can be accessed. The following steps are given to create the disks.

 fdisk /dev/sdb

 In the same way, total of five disks are created. After creating these disks, reboot your Operating
System to save the changes.
Downloading and Installing Library for ASM
To install ASM (Automatic Storage Management), I have downloaded two libraries which I will install
as RPM. These two libraries listed below has to be installed as root user:

 oracleasm-support-2.0.1-1.i386.rpm

 oracleasmlib-2.0.1-1.i386.rpm

Configuring Oracle ASM library driver


It is very necessary to configure ASM so that it can know and access the disks that we created above.
Default user and default group for this configuration will be oracle and oinstall respectively. Moreover,
you will also tag yes(y) on both the questions. We will also be tagging and labelling the disks to ASM
through following codes.

 /etc/init.d/oracleasm configure
 /etc/init.d/oracleasm createdisk VOL1 /dev/sda8

 /etc/init.d/oracleasm createdisk VOL1 /dev/sda9


 /etc/init.d/oracleasm createdisk VOL1 /dev/sda10
 /etc/init.d/oracleasm createdisk VOL1 /dev/sda11
 /etc/init.d/oracleasm createdisk VOL1 /dev/sda12

After completing the steps above, check the partitions whether if it is labelled to ASM or not. Then,
reboot the system to save the changes.
1. oracleasm listdisk
Installing Grid Infrastructure
Another thing that needs to be done before installing oracle is to install the grid infrastructure. Here we
will also create ASM disk group called DATA so that the file is stored equally in all the three disks.
These data are redundant so that the user can recover all the files even when database is corrupt. The
installation file can be found on the Operating System disk.
1. After tagging disk to ASM, you will need to unzip the grid files.
2. Then run the ./runInstaller file inside the above unzipped folder.

3. After running the file, installation window will appear as below

4. Then check the Skip software updates and click on Next.


5. Choose the standalone Server from the following list and click next.
6. Choose the default language of English
7. After the language, create an ASM disk group called data with external redundancy on three
disks.

8. On the next step, you will need to set up the ASM password. We will use same password for all
the accounts.
9. Then choose the default operating system groups and click on next. These groups were created
manually by groupadd in the first period of grid installation.

10. These locations will also be default location, so you will not need to change the location as well
11. After clicking on next, the prerequisite check will check if the environment variable and kernel
were set correctly. If not then the check will fail.

12. After checking all the requirements, a summary will appear saying everything is fine and is
ready to install.
13. Click on install and wait for installation to be complete.

14. Finally, you’ll need to execute a root script as a root user to complete the installation. The
script is also given by the Installer
15. After completing the installation, reboot your system to save the changes.
Configuring ASM
If you wish to configure Automatic Storage Management (ASM), all you need to do is following points.
It will show adding or creating new disk group in the following while you can also mount and unmount
the disk from the ASM. Here disk group FRA is created.
1. You will firstly type asmca (Automatic Storage Management Configuration Assistant) in the
terminal of grid user.

2. Then asmca screen will appear with disk groups that exist.

3. Click on create and a create disk screen will appear. Choose the external redundancy and click on
both the remaining disk and also give the disk group name as FRA and click on Ok.
4. This will create a disk group called FRA and will take some time to complete. A disk group
message will show up after the completion.
Installing Oracle Database Infrastructure
Last thing to do before creating the database is to setup the database infrastructure. To install the
database infrastructure, two files from the OS disk image should be copied or unzipped. This will create
a directory called database where .runInstaller file can be found. After installing the file, database can
be successfully created.
1. Firstly, switch the user into oracle and copy the files from the Image file of OS.
2. Then, unzip both the files as below.

3. After unzipping both the files, it will create a directory called database. Inside the directory an
installation file will be found. Run the file for further installation(./runInstaller).

4. After running the file, an installation screen will appear where you will unselect the security
updates by Oracle Support and click on next.
5. Next select skip the software updates as below and click on next.
6. Since this is the first installation of database, select Install database software only.

7. Select Single Instance database and always choose English as default language.

8. Select the Enterprise Edition while selecting the database edition.


9. Click next with default installation location and groups. This will choose the default directory and
default user groups that we made at the start.

10. Then, a prerequisite check will be performed to verify the target environment with the minimum
requirement and configuration requirement.
11. Finally, its ready to install. Click on install button and the installation will start.

12. In the middle of installation, a root script will popup which needs to be executed in the root
account.
13. After running the scripts in the root account, a message will be displayed saying installation is
successfully complete.

Creating a Database (SuperStore)


Before creating the tables and loading data into tables, creating the database is the first thing to do.
After creating the database, you can create tables into the system.
1. Firstly, log into the oracle account and type dbca on the terminal.

2. A dialog box of database configuration assistant will appear. Click on Next.


3. Then in the next two steps, choose create a database and general purpose or Transaction Processing

4. Next, a database name and SID would be required while creating the database. Click on next after
naming the database.

5. Choose the second one and confirm the password while setting up the database credentials.
6. Then select ASM as storage type and browse +DATA as database area and click on next.

7. Next, browse fast recovery as +FRA and leave the size to default for database recovery options.

8. Unselect the sample schemas and select the use Automatic Meomory Management in the next two
steps.
9. Click
next and
select
on create

database to start the installation

10. Wait till the installation is complete. Then reboot the server.
Interacting database with a SQLTools
1. Firstly, download the tool called SQLTools from the Internet. It is free.
2. Then open the SQLTool, an Interface will appear. Fill up the username, password, host server ip
address, tcp port, SID and mode to connect with the database.

3. After clicking on Connect button after filling up the form, it will connect to that server as a user.
SID will define which database to connect.
4. Now after connecting to the database, users will be able to work on the database easily.
Firstly, Connect the server from SQLTools as sysdba. Only system administrator or user with the role
of dba can create tablespace.

Creating tablespace

CREATE TABLESPACE HR_DBS


DATAFILE '+DATA' SIZE 1000M AUTOEXTEND ON NEXT 100M
MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT
LOCAL SEGMENT SPACE MANAGEMENT AUTO;

Creating Temporary TableSpace

CREATE TEMPORARY TABLESPACE temp_hrdba

TEMPFILE '+DATA(DATAFILE)/HRDB_TEMP_DATAFILE' SIZE 100M

AUTOEXTEND ON NEXT 100M

MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL UNIFORM SIZE 10M;

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp_hrdba;

Creating Undo Table Space

CREATE UNDO TABLESPACE hrdb_undo


DATAFILE '+DATA(DATAFILE)/HRDB_UNDO_DATA'
SIZE 1000M AUTOEXTEND ON NEXT 100M
MAXSIZE UNLIMITED RETENTION GUARANTEE;
ALTER system SET undo_tablespace=hrdb_undo scope=both undo_retention=5;
After successfully creating the tablespace, next thing will be creating a user authentication or password
verification function so that Users password are secure and cannot be guessed or hacked. This function
will not let the user set the password as the username and vice-versa. It will also set the minimum
length for the password. Moreover, the following function will not allow any simple values and will
also need one character and number. There are basically two functions for staff and dba.

User Security/Password Verification functions


creating verification function for dba(HRDB)
CREATE OR REPLACE FUNCTION HRDB_verification
(username varchar2,
password varchar2,
old_password varchar2)
RETURN boolean IS
n boolean;
m integer;
differ integer;
isdigit boolean; --for password complexity
ischar boolean; --for password complexity
ispunct boolean; --for password complexity
digitarray varchar2(20);
punctarray varchar2(25);
chararray varchar2(52);
BEGIN
-- Check if the password is same as the username
IF NLS_LOWER(password) = NLS_LOWER(username) THEN
raise_application_error(-20001, 'Password same as or similar to user');
END IF;
-- Check for the minimum length of the password
IF length(password) < 4 THEN
raise_application_error(-20002, 'Password length less than 4');
END IF
-- Check if the password is too simple. A dictionary of words may be
-- maintained and a check may be made so as not to allow the words
-- that are too simple for the password.
IF NLS_LOWER(password) IN ('welcome', 'database', 'account', 'user', 'password', 'oracle',
'computer', 'abcd') THEN
raise_application_error(-20002, 'Password too simple');
END IF;

Creating Password Complexity Function for Staff


CREATE OR REPLACE FUNCTION Staff_password_complex
(username varchar2,
password varchar2,
old_password varchar2)
RETURN boolean IS
n boolean;
m integer;
differ integer;
isdigit boolean;
ischar boolean;
ispunct boolean;
db_name varchar2(40);
digitarray varchar2(20);
punctarray varchar2(25);
chararray varchar2(52);
i_char varchar2(10);
simple_password varchar2(10);
reverse_user varchar2(32);
BEGIN
digitarray:= '0123456789';
chararray:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-- Check for the minimum length of the password
IF length(password) < 8 THEN
raise_application_error(-20001, 'Password length less than 8');
END IF;
-- Check if the password is same as the username or username(1-100)
IF NLS_LOWER(password) = NLS_LOWER(username) THEN
raise_application_error(-20002, 'Password same as or similar to username');
END IF;
FOR i IN 1..100 LOOP
i_char := to_char(i);
if NLS_LOWER(username)|| i_char = NLS_LOWER(password) THEN
raise_application_error(-20005, 'Password same as or similar to user name ');
END IF;
END LOOP;
-- Check if the password is same as the username reversed
FOR i in REVERSE 1..length(username) LOOP
reverse_user := reverse_user || substr(username, i, 1);
END LOOP;
IF NLS_LOWER(password) = NLS_LOWER(reverse_user) THEN
raise_application_error(-20003, 'Password same as username reversed');
END IF;
-- Check if the password is too simple. A dictionary of words may be
IF NLS_LOWER(password) IN ('welcome1', 'database1', 'account1', 'user1234', 'password1',
'oracle123', 'computer1', 'abcdefg1', 'change_on_install') THEN
raise_application_error(-20006, 'Password too simple');
END IF;
-- Check if the password is the same as oracle (1-100)
simple_password := 'oracle';
FOR i IN 1..100 LOOP
i_char := to_char(i);
if simple_password || i_char = NLS_LOWER(password) THEN
raise_application_error(-20007, 'Password too simple ');
END IF;
END LOOP;
-- Check if the password contains at least one letter, one digit
Check for the digit

isdigit:=FALSE;
m := length(password);
FOR i IN 1..10 LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(digitarray,i,1) THEN
isdigit:=TRUE;
GOTO findchar;
END IF;
END LOOP;
END LOOP;
IF isdigit = FALSE THEN
raise_application_error(-20008, 'Password must contain at least one digit, one character');
END IF;

Check for the character


<<findchar>>
ischar:=FALSE;
FOR i IN 1..length(chararray) LOOPFOR j IN 1..m LOOP IF substr(password,j,1) =
substr(chararray,i,1)
THENischar:=TRUE;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF ischar = FALSE THEN
raise_application_error(-20009, 'Password must contain at least one digit, and one character');
END IF;
<<endsearch>>
Check if the password differs from the previous password by at least 3 letter
IF old_password IS NOT NULL THEN
differ := length(old_password) - length(password);
differ := abs(differ);
IF differ < 3 THEN
IF length(password) < length(old_password) THEN
m := length(password);
ELSE
m := length(old_password);
END IF;
FOR i IN 1..m LOOP
IF substr(password,i,1) != substr(old_password,i,1) THEN
differ := differ + 1;
END IF;
END LOOP;
IF differ < 3 THEN
raise_application_error(-20011, 'Password should differ from the \
old password by at least 3 characters');
END IF;
END IF;
END IF;
-- Everything is fine; return TRUE ;
RETURN(TRUE);
END;
/
IF substr(password,j,1) = substr(chararray,i,1) THEN
ischar:=TRUE;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF ischar = FALSE THEN
raise_application_error(-20009, 'Password must contain at least one digit, and one character');
END IF;
<<endsearch>>
These two functions are assigned to profile as a password verification function. I have made major two
profiles for different users. SuperStore_Profile will only be assigned to DBA while Staff_Profile will be
assigned to all the other staffs that are related to SuperStore. These profiles will also maintain the User
Security by locking the account if the user hits three wrong passwords continuously. It will also define
life time of password and also other properties.

Creating Profiles/ User Profiling

Creating Profile for DBA(HRDB)


CREATE PROFILE HRDB_profile LIMIT
CPU_PER_CALL DEFAULT
CONNECT_TIME DEFAULT
IDLE_TIME 60
SESSIONS_PER_USER 10
LOGICAL_READS_PER_SESSION DEFAULT
LOGICAL_READS_PER_CALL DEFAULT
PRIVATE_SGA DEFAULT
COMPOSITE_LIMIT DEFAULT
FAILED_LOGIN_ATTEMPTS 3 -- Account locked after 3 failed logins.
PASSWORD_LOCK_TIME 5 -- Number of days account is locked for. UNLIMITED required
explicit unlock by DBA.
PASSWORD_LIFE_TIME 30 -- Password expires after 90 days.
PASSWORD_GRACE_TIME 3 -- Grace period for password expiration.
PASSWORD_REUSE_TIME 120 -- Number of days until a specific password can be reused.
UNLIMITED means never.
PASSWORD_REUSE_MAX 10 -- The number of changes required before a password can be
reused. UNLIMITED means never.
PASSWORD_VERIFY_FUNCTION HRDB_verification;
Creating Profile for Staff
CREATE PROFILE Staff_Profile LIMIT CPU_PER_SESSION DEFAULT
CPU_PER_CALL DEFAULT
CONNECT_TIME DEFAULT
IDLE_TIME 60
LOGICAL_READS_PER_SESSION DEFAULT
LOGICAL_READS_PER_CALL DEFAULT
PRIVATE_SGA DEFAULT
COMPOSITE_LIMIT DEFAULT
PASSWORD_LIFE_TIME 30
PASSWORD_GRACE_TIME 30
PASSWORD_REUSE_MAX 1
PASSWORD_REUSE_TIME UNLIMITED
PASSWORD_LOCK_TIME 5
FAILED_LOGIN_ATTEMPTS 3
PASSWORD_VERIFY_FUNCTION Staff_password_complex;

After creating two profiles, I have created users according to my business need. Since my business
requirement is dependent on Super Store, Users can be accountant, Staff and also the analyst. Though
there is always a DBA user.

Creating Users and granting tablespace


Creating User(HRDB)
CREATE USER SuperStore
PROFILE SuperStore_Profile
IDENTIFIED BY 12345678 PASSWORD EXPIRE
DEFAULT TABLESPACE SuperStore_TableSpace
TEMPORARY TABLESPACE TEMP_SuperStore ACCOUNT UNLOCK;
Granting privileges as DBA to hrdb
GRANT CONNECT,RESOURCE,DBA TO hrdb;
Creating tables (Changing ER diagram into Physical tables)

Creating table Jobs


CREATE table Jobs (
job_id NUMBER Not NULL,
job_title VARCHAR2(20) NOT NULL,
min_salary VARCHAR2(20) NOT NULL,
max_salary VARCHAR2(20) NOT NULL,
CONSTRAINT JOBS_ID_PK PRIMARY KEY (job_id)
);

Creating table Regions


CREATE table Regions (
region_id NUMBER NOT NULL,
region_name VARCHAR2(200) NOT NULL,
CONSTRAINT REGION_ID_PK PRIMARY KEY (region_id)
);
Creating table Product_Information
CREATE table Product_Information (
product_id NUMBER NOT NULL,
product_name VARCHAR2(200) NOT NULL,
product_description VARCHAR2(200) NOT NULL,
category_id VARCHAR2(200) NOT NULL,
weight_class VARCHAR2(200) NOT NULL,
warranty_period VARCHAR2(200) NOT NULL,
supplier_id NUMBER NOT NULL,
product_status VARCHAR2(200) NOT NULL,
list_price VARCHAR2 (200) NOT NULL,
min_price VARCHAR2(200) NOT NULL,
catalog_url VARCHAR2 (200) NOT NULL,
CONSTRAINT PRODUCT_INFORMATION_ID_PK PRIMARY KEY (product_id)
);

Creating table Countries


CREATE table Countries (
country_id NUMBER NOT NULL,
country_name VARCHAR2(200) NOT NULL,
region_id NUMBER NOT NULL,
CONSTRAINT COUNTRY_ID_PK PRIMARY KEY (country_id),
CONSTRAINT "REGION_ID_FK" FOREIGN KEY (region_id)
REFERENCES Regions (region_id)
);
Creating table Customers
CREATE table Customers (
customer_id NUMBER NOT NULL,
cust_first_name VARCHAR2(200) NOT NULL,
cust_last_name VARCHAR2(200) NOT NULL,
cust_adress VARCHAR2(200) NOT NULL,
phone_number VARCHAR2(200) NOT NULL,
nls_language VARCHAR2(200) NOT NULL,
nls_territory VARCHAR2(200) NOT NULL,
credit_limit VARCHAR2(200) NOT NULL,
account_mgr_id VARCHAR2(200) NOT NULL,
cust_geo_location VARCHAR2(200) NOT NULL,
data_of_birth date NOT NULL,
marital_status VARCHAR2(200) NOT NULL,
gender Char(1) NOT NULL,
income_level VARCHAR2(200) NOT NULL,
CONSTRAINT CUSTOMERS_ID_PK PRIMARY KEY (customer_id)
)
PARTITION BY list(income_level)(
PARTITION income_level_A VALUES ('A: Below 30,000'),
PARTITION income_level_B VALUES ('B: 30,000 - 49,999'),
PARTITION income_level_C VALUES ('C: 50,000 - 69,999'),
PARTITION income_level_D VALUES ('D: 70,000 - 89,999'),
PARTITION income_level_E VALUES ('E: 90,000 - 109,999'),
PARTITION income_level_F VALUES ('F: 110,000 - 129,999'),
PARTITION income_level_G VALUES ('G: 130,000 - 149,999'),
PARTITION income_level_H VALUES ('H: 150,000 - 169,999'),
PARTITION income_level_I VALUES ('I: 170,000 - 189,999'),
PARTITION income_level_J VALUES ('J: 190,000 - 249,999'),
PARTITION income_level_K VALUES ('K: 250,000 - 299,999'),
PARTITION income_level_L VALUES ('L: 300,000 and above'),
PARTITION income_level_null VALUES ('not specified')
) ENABLE ROW MOVEMENT;
/

Creating table Locations


CREATE table Locations (
location_id NUMBER NOT NULL,
street_adress VARCHAR2(200) NOT NULL,
postal_code VARCHAR2(200) NOT NULL,
city VARCHAR2(200) NOT NULL,
state_province VARCHAR2(200) NOT NULL,
country_id NUMBER NOT NULL,
CONSTRAINT LOCATION_ID_PK PRIMARY KEY (location_id),
CONSTRAINT "COUNTRY_ID_FK" FOREIGN KEY (country_id)
REFERENCES Countries (country_id)
);

Creating table Departments


CREATE table Departments(
department_id NUMBER NOT NULL,
department_name VARCHAR2(20) Not NULL,
location_id NUMBER NOT NULL,
CONSTRAINT DEPARTMENT_ID_PK PRIMARY KEY (department_id),
CONSTRAINT "LOCATION_ID_FK" FOREIGN KEY (location_id)
REFERENCES Locations (location_id)
);
Creating table Managers
CREATE table Managers (
manager_id NUMBER NOT NULL,
department_id NUMBER NOT NULL,
CONSTRAINT MANAGER_ID_PK PRIMARY KEY (manager_id),
CONSTRAINT "DEPARTMENT_ID_FKM" FOREIGN KEY (department_id)
REFERENCES Departments (department_id)
);

Creating table Job History


CREATE table Job_History (
employee_id NUMBER NOT NULL,
start_date date NOT NULL,
end_date DATE NOT Null,
job_id NUMBER NOT NULL,
department_id NUMBER NOT NULL,
CONSTRAINT "EMPLOYEE_ID_FKJH" FOREIGN KEY (employee_id)
REFERENCES Employees (employee_id),
CONSTRAINT "JOBS_ID_FKJH" FOREIGN KEY (job_id)
REFERENCES Jobs (job_id),
CONSTRAINT "DEPARTMENT_ID_FKJH" FOREIGN KEY (department_id)
REFERENCES Departments (department_id)
);
Creating table Employees
CREATE table Employees (
employee_id NUMBER NOT NULL,
first_name VARCHAR2(200),
last_name VARCHAR2(200),
email VARCHAR2(200),
phone_number NUMBER NOT NULL,
hire_date date,
job_id NUMBER NOT NULL,
salary VARCHAR2 (200) NOT NULL,
commission_pct NUMBER(3,2),
manager_id NUMBER,
department_id NUMBER,
CONSTRAINT EMPLOYEE_ID_PK PRIMARY KEY (employee_id),
CONSTRAINT "JOBS_ID_FK" FOREIGN KEY (job_id)
REFERENCES Jobs (job_id),
CONSTRAINT "MANAGER_ID_FK" FOREIGN KEY (manager_id)
REFERENCES Managers (manager_id),
CONSTRAINT "DEPARTMENT_ID_FKE" FOREIGN KEY (department_id)
REFERENCES Departments (department_id)
)
PARTITION BY list(salary)(
PARTITION salary_A VALUES ('A: Below 3000'),
PARTITION salary_B VALUES ('B: 3000 - 5999'),
PARTITION salary_C VALUES ('C: 6000 - 8999'),
PARTITION salary_D VALUES ('D: 9000 - 10,999'),
PARTITION salary_E VALUES ('E: 11,000 - 14,999'),
PARTITION salary_F VALUES ('F: 15,000 - 18,999'),
PARTITION salary_G VALUES ('G: 19,000 - 22,999'),
PARTITION salary_H VALUES ('H: 23,000 and above'),
PARTITION salary_null VALUES ('not specified')
) ENABLE ROW MOVEMENT;
Creating table Warehouse
CREATE table Warehouse (
warehouse_id NUMBER NOT NULL,
warehouse_spec VARCHAR2(200) NOT NULL,
warehouse_name VARCHAR2(200) NOT NULL,
location_id NUMBER NOT NULL,
wh_geo_location VARCHAR2(200) NOT Null,
CONSTRAINT WAREHOUSE_ID_PK PRIMARY KEY (warehouse_id),
CONSTRAINT "LOCATION_ID_FKWH" FOREIGN KEY (location_id)
REFERENCES Locations (location_id)
); CONSTRAINT "JOBS_ID_FKJH" FOREIGN KEY (job_id)
REFERENCES Jobs (job_id),
CONSTRAINT "DEPARTMENT_ID_FKJH" FOREIGN KEY (department_id)
REFERENCES Departments (department_id)
);

Creating table Inventories


CREATE table Inventories (
product_id NUMBER NOT NULL,
warehouse_id NUMBER NOT NULL,
quantity_on_hand NUMBER NOT NULL,
CONSTRAINT "PRODUCT_ID_FK" FOREIGN KEY (product_id)
REFERENCES Product_Information (product_id),
CONSTRAINT "WAREHOUSE_ID_FK" FOREIGN KEY (warehouse_id)
REFERENCES Warehouse (warehouse_id)
);
Creating table Orders
CREATE table Orders(
order_id NUMBER NOT NULL,
order_date date NOT NULL,
order_mode VARCHAR2(200) NOT NULL,
customer_id NUMBER NOT NULL,
order_status VARCHAR2(200) NOT Null,
order_total NUMBER NOT NULL,
sales_rep_id NUMBER NOT null,
promotion_id NUMBER NOT null,
CONSTRAINT ORDER_ID_PK PRIMARY KEY (order_id),
CONSTRAINT "CUSTOMERS_ID_FK" FOREIGN KEY (customer_id)
REFERENCES Customers (customer_id),
CONSTRAINT "SALES_REP_ID_FK" FOREIGN KEY (sales_rep_id)
REFERENCES Employees (employee_id)
);

Creating table Order_Items


CREATE table Order_Items(
order_id NUMBER NOT NULL,
line_item_id Number NOT NULL,
product_id NUMBER NOT NULL,
unit_price NUMBER,
quantity NUMBER NOT NULL,
CONSTRAINT "ORDER_ID_FK" FOREIGN KEY (order_id)
REFERENCES Orders(order_id),
CONSTRAINT "PRODUCT_ID_FKOI" FOREIGN KEY (product_id)
REFERENCES Product_Information (product_id)
);
After creating or changing these tables physically from ER diagram, Auditing database and ETL will be
the next part

Auditing
Here I have done two type of auditing. Fine Grained Auditing and Standard Database Auditing. Run the
code below on SQLTools to audit the database.

 Database Auditing
Auditing for hrdb
AUDIT ALL BY hrdb BY ACCESS;
AUDIT SELECT TABLE, UPDATE TABLE, INSERT TABLE, DELETE TABLE BY hrdb BY
ACCESS;
AUDIT EXECUTE PROCEDURE BY hrdb BY ACCESS;

SELECT * FROM sys.aud$


WHERE userid='hrdb';
SELECT userid, TIMESTAMP#,userhost,terminal,action#,sqltext FROM sys.aud$ WHERE
userid='hrdb';
SELECT * FROM DBA_AUDIT_TRAIL WHERE owner='hrdb';
SELECT os_username,userhost,action_name,obj_name FROM DBA_AUDIT_TRAIL WHERE
Lower(username)='hrdb';
SELECT * FROM dba_common_audit_trail;
SELECT * FROM dba_fga_audit_trail;

SELECT db_user,extended_timestamp,object_schema,object_name,action
FROM v$xml_audit_trail
WHERE object_schema = 'hrdb'
ORDER BY extended_timestamp;

 Fine Grained Auditing

Fine grained Auditing for Jobs


BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'JOBS',
policy_name => 'JOBS_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/
Fine grained Auditing for Regions
BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'REGIONS',
policy_name => 'REGIONS_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/

Fine grained Auditing for PRODUCT_INFORMATION

BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'PRODUCT_INFORMATION',
policy_name => 'PRODUCT_INFORMATION_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/
EXEC dbms_fga.drop_policy('SuperStore','districtS','districts_AUDIT');
Fine grained Auditing for CUSTOMERS
BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'CUSTOMERS',
policy_name => 'CUSTOMERS_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/

Fine grained Auditing for COUNTRIES


BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'COUNTRIES',
policy_name => 'COUNTRIES_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/

Fine grained Auditing for LOCATIONS


BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'LOCATIONS',
policy_name => 'LOCATIONS_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/

Fine grained Auditing for DEPARTMENTS


BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'DEPARTMENTS',
policy_name => 'DEPARTMENTS_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/

Fine grained Auditing for EMPLOYEES


BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'EMPLOYEES',
policy_name => 'EMPLOYEES_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/

Fine grained Auditing for ORDER_ITEMS


BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'ORDER_ITEMS',
policy_name => 'ORDER_ITEMS_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/
Fine grained Auditing for JOB_HISTORY
BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'JOB_HISTORY',
policy_name => 'JOB_HISTORY_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/
Fine grained Auditing for WAREHOUSE
BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'ORDERS',
policy_name => 'ORDERS_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
Fine grained Auditing for ORDERS
BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'ORDERS',
policy_name => 'ORDERS_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/
Fine grained Auditing for INVENTORIES
BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'INVENTORIES',
policy_name => 'INVENTORIES_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/

Fine grained Auditing for MANAGERS


BEGIN
DBMS_FGA.add_policy(
object_schema => 'hrdb',
object_name => 'MANAGERS',
policy_name => 'MANAGERS_AUDIT',
audit_condition => NULL,
audit_column => NULL,
statement_types => 'SELECT,INSERT,UPDATE,DELETE');
END;
/

To confirm
SELECT session_id,TIMESTAMP,db_user,
os_user,userhost,object_schema,
object_name,policy_name,statement_type,
sql_text FROM dba_fga_audit_trail;
SELECT * FROM dba_fga_audit_trail;
/
COMMIT;

Roles
Than after auditing role was defined.

CREATE USER manager


PROFILE HRDB_profile
IDENTIFIED BY password123
DEFAULT TABLESPACE HR_DBS
TEMPORARY TABLESPACE temp_hrdba ACCOUNT UNLOCK;
Grant select, INSERT,UPDATE,delete on hrdb.jobs to manager;
Grant select, INSERT,UPDATE,delete on hrdb.regions to manager;
Grant select, INSERT,UPDATE,delete on hrdb.product_information to manager;
Grant select, INSERT,UPDATE,delete on hrdb.customers to manager;
Grant select, INSERT,UPDATE,delete on hrdb.countries to manager;
Grant select, INSERT,UPDATE,delete on hrdb.locations to manager;
Grant select, INSERT,UPDATE,delete on hrdb.departments to manager;
Grant select, INSERT,UPDATE,delete on hrdb.managers to manager;
Grant select, INSERT,UPDATE,delete on hrdb.employees to manager;
Grant select, INSERT,UPDATE,delete on hrdb.warehouse to manager;
Grant select, INSERT,UPDATE,delete on hrdb.orders to manager;
Grant select, INSERT,UPDATE,delete on hrdb.job_history to manager;
Grant select, INSERT,UPDATE,delete on hrdb.inventories to manager;
Grant select, INSERT,UPDATE,delete on hrdb.order_items to manager;

RMAN
Catdb database has been created just like HRDB as sys user and following command was executed.

RMAN
CREATE TABLESPACE rman DATAFILE '+DATA/RMANH_DATAFILE'
SIZE 1000M AUTOEXTEND ON NEXT 100M
MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT
LOCAL SEGMENT SPACE MANAGEMENT AUTO;

RMAN Tablespace
CREATE USER rman IDENTIFIED BY rman
DEFAULT TABLESPACE rman
QUOTA UNLIMITED ON rman
ACCOUNT UNLOCK;

RMAN User
GRANT connect, resource, recovery_catalog_owner TO rman;
DROP TABLESPACE rman;
DROP USER rman;
DROP USER vpcuser;

CREATE USER vpcuser IDENTIFIED BY vpcuser;


grant connect, resource, recovery_catalog_owner TO vpcuser;

Then Oracle is connected in OS level and following commands were executed.

$ rman catalog rma/rman@catdb

All the information related to catalog is stored in “rman” tablespace

RMAN> create catalog tablespace rman;


RMAN> EXIT

After verifying register and listing incarnation

Create user hrbd identified by hrdb;


Grant connect resource, recovery_catalog_owner to db1;

New database db1 was created and registered in catdb

$ rman target sys/password@hrdb catalog rman/rman@catdb


RMAN> grant catalog for db1 to hrdb
RMAN> host;
After that Virtual catalog was created

RMAN> create virtual catalog


RMAN> list incarnation
RMAN> EXIT;

Scheduling
After configuring RMAN, backup was made automated.

BEGIN
sys.dbms_scheduler.create_job(
job_name => '"SYS"."Full_backup"',
job_type => 'EXECUTABLE',
job_action => '/u01/app/sh/fullbackup.sh',
repeat_interval => 'FREQ=DAILY;BYDAY=SAT;BYHOUR=2;BYMINUTE=0;BYSECOND=0',
start_date => systimestamp at time zone 'America/New_York',
job_class => '"DEFAULT_JOB_CLASS"',
auto_drop => FALSE,
enabled => FALSE);
sys.dbms_scheduler.set_attribute( name => '"SYS"."Full_backup"', attribute => 'raise_events', value =>
dbms_scheduler.job_started + dbms_scheduler.job_succeeded + dbms_scheduler.job_failed);
sys.dbms_scheduler.enable( '"SYS"."Full_backup"' );
END;
Performing ETL
 Making control file
 Loading data into staging table
 Making main table
 Inserting into main table

LOAD DATA

INFILE '/u01/app/external/ jobs.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_ jobs
FIELDS TERMINATED BY '|'
(
job_id NUMBER,
job_title CHAR(20),
min_salary CHAR(20),
max_salary CHAR(20)
)
-------making control file
CREATE table ext_Jobs (
job_id NUMBER Not NULL,
job_title VARCHAR2(20) NOT NULL,
min_salary VARCHAR2(20) NOT NULL,
max_salary VARCHAR2(20) NOT NULL
);
--DROP TABLE ext_transaction_type;
--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ jobs.ctl log=/u01/app/ext/


jobs.log bad=/u01/app/ext/ jobs.bad;

------loading data into staging table

CREATE table Jobs (


job_id NUMBER Not NULL,
job_title VARCHAR2(20) NOT NULL,
min_salary VARCHAR2(20) NOT NULL,
max_salary VARCHAR2(20) NOT NULL,
CONSTRAINT JOBS_ID_PK PRIMARY KEY (job_id)
);
------making main table

INSERT INTO jobs


SELECT
job_id, job_title, min_salary, max_salary
FROM ext_jobs;
----inserting into main table
LOAD DATA

INFILE '/u01/app/external/ regions.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_ regions
FIELDS TERMINATED BY '|'
(
region_id NUMBER ,
region_name CHAR(200)
)

-------making control file

CREATE table ext_Jobs (


region_id NUMBER,
region_name VARCHAR2(200)
);

--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ regions.ctl log=/u01/app/ext/


regions.log bad=/u01/app/ext/ regions.bad;

------loading data into staging table

CREATE table Regions (


region_id NUMBER NOT NULL,
region_name VARCHAR2(200) NOT NULL,
CONSTRAINT REGION_ID_PK PRIMARY KEY (region_id)
); ------making main table

INSERT INTO regions


SELECT
region_id,
FROM ext_jobs, region_name
----inserting into main table
LOAD DATA

INFILE '/u01/app/external/ Product_Information.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_ Product_Information
FIELDS TERMINATED BY '|'
(
product_id NUMBER ,
product_name CHAR(200) ,
product_description CHAR(200) ,
category_id CHAR(200) ,
weight_class CHAR(200) ,
warranty_period CHAR(200) ,
supplier_id NUMBER ,
product_status CHAR(200) ,
list_price CHAR (200) ,
min_price CHAR(200) ,
catalog_url CHAR (200))
-------making control file

CREATE table ext_ Product_Information (


product_id NUMBER NOT NULL,
product_name VARCHAR2(200),
product_description VARCHAR2(200),
category_id VARCHAR2(200),
weight_class VARCHAR2(200),
warranty_period VARCHAR2(200),
supplier_id NUMBER,
product_status VARCHAR2(200),
list_price VARCHAR2 (200),
min_price VARCHAR2(200),
catalog_url VARCHAR2 (200)
);
--DROP TABLE ext_transaction_type;
--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Product_Information.ctl


log=/u01/app/ext/ Product_Information.log bad=/u01/app/ext/ Product_Information.bad;

------loading data into staging table

CREATE table Product_Information (


product_id NUMBER NOT NULL,
product_name VARCHAR2(200) NOT NULL,
product_description VARCHAR2(200) NOT NULL,
category_id VARCHAR2(200) NOT NULL,
weight_class VARCHAR2(200) NOT NULL,
warranty_period VARCHAR2(200) NOT NULL,
supplier_id NUMBER NOT NULL,
product_status VARCHAR2(200) NOT NULL,
list_price VARCHAR2 (200) NOT NULL,
min_price VARCHAR2(200) NOT NULL,
catalog_url VARCHAR2 (200) NOT NULL,
CONSTRAINT PRODUCT_INFORMATION_ID_PK PRIMARY KEY (product_id)
); ------making main table

INSERT INTO Product_Information


SELECT
product_id, product_name, product_description, category_id, weight_class, warranty_period,
supplier_id, product_status, list_price, min_price, catalog_url
FROM ext_ Product_Information;
----inserting into main table

LOAD DATA

INFILE '/u01/app/external/ Customers.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_ Customers
FIELDS TERMINATED BY '|'
(
customer_id NUMBER ,
cust_first_name CHAR(200) ,
cust_last_name CHAR(200) ,
cust_adress CHAR(200) ,
phone_number CHAR(200) ,
nls_language CHAR(200) ,
nls_territory CHAR(200) ,
credit_limit CHAR(200) ,
account_mgr_id CHAR(200) ,
cust_geo_location CHAR(200) ,
data_of_birth date ,
marital_status CHAR(200) ,
gender Char(1) ,
income_level CHAR(200))
-------making control file

CREATE table ext_Customers (


customer_id NUMBER NOT NULL,
cust_first_name VARCHAR2(200),
cust_last_name VARCHAR2(200),
cust_adress VARCHAR2(200),
phone_number VARCHAR2(200),
nls_language VARCHAR2(200),
nls_territory VARCHAR2(200),
credit_limit VARCHAR2(200),
account_mgr_id VARCHAR2(200),
cust_geo_location VARCHAR2(200),
data_of_birth date NOT NULL,
marital_status VARCHAR2(200),
gender Char(1),
income_level VARCHAR2(200)
);
--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Customers.ctl log=/u01/app/ext/


Customers.log bad=/u01/app/ext/ Customers.bad;
------loading data into staging table

CREATE table Customers (


customer_id NUMBER NOT NULL,
cust_first_name VARCHAR2(200) NOT NULL,
cust_last_name VARCHAR2(200) NOT NULL,
cust_adress VARCHAR2(200) NOT NULL,
phone_number VARCHAR2(200) NOT NULL,
nls_language VARCHAR2(200) NOT NULL,
nls_territory VARCHAR2(200) NOT NULL,
credit_limit VARCHAR2(200) NOT NULL,
account_mgr_id VARCHAR2(200) NOT NULL,
cust_geo_location VARCHAR2(200) NOT NULL,
data_of_birth date NOT NULL,
marital_status VARCHAR2(200) NOT NULL,
gender Char(1) NOT NULL,
income_level VARCHAR2(200) NOT NULL,
CONSTRAINT CUSTOMERS_ID_PK PRIMARY KEY (customer_id)
) ------making main table

INSERT INTO Customers


SELECT
customer_id, cust_first_name, cust_last_name, cust_adress, phone_number, nls_language,
nls_territory, credit_limit, account_mgr_id, cust_geo_location, data_of_birth, marital_status,
gender, income_level
FROM ext_Customers;
----inserting into main table
LOAD DATA

INFILE '/u01/app/external/ Countries.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_ Countries
FIELDS TERMINATED BY '|'
(
country_id NUMBER ,
country_name CHAR(200) ,
region_id NUMBER)
-------making control file

CREATE table ext_Countries (


country_id NUMBER,
country_name VARCHAR2(200),
region_id NUMBER
);
--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Countries.ctl log=/u01/app/ext/


Countries.log bad=/u01/app/ext/ Countries.bad;

------loading data into staging table

CREATE table Countries (


country_id NUMBER NOT NULL,
country_name VARCHAR2(200) NOT NULL,
region_id NUMBER NOT NULL,
CONSTRAINT COUNTRY_ID_PK PRIMARY KEY (country_id),
CONSTRAINT "REGION_ID_FK" FOREIGN KEY (region_id)
REFERENCES Regions (region_id));
------making main table

INSERT INTO Countries


SELECT
country_id, country_name, region_id
FROM ext_jobs;
----inserting into main table
LOAD DATA

INFILE '/u01/app/external/ Locations.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_ Locations
FIELDS TERMINATED BY '|'
(
location_id NUMBER ,
street_adress CHAR(200) ,
postal_code CHAR(200) ,
city CHAR(200) ,
state_province CHAR(200) ,
country_id NUMBER)
-------making control file

CREATE table ext_Locations (


location_id NUMBER,
street_adress VARCHAR2(200),
postal_code VARCHAR2(200),
city VARCHAR2(200),
state_province VARCHAR2(200),
country_id NUMBER
);

--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Locations.ctl log=/u01/app/ext/


Locations.log bad=/u01/app/ext/ Locations.bad;

------loading data into staging table

CREATE table Locations (


location_id NUMBER NOT NULL,
street_adress VARCHAR2(200) NOT NULL,
postal_code VARCHAR2(200) NOT NULL,
city VARCHAR2(200) NOT NULL,
state_province VARCHAR2(200) NOT NULL,
country_id NUMBER NOT NULL,
CONSTRAINT LOCATION_ID_PK PRIMARY KEY (location_id),
CONSTRAINT "COUNTRY_ID_FK" FOREIGN KEY (country_id)
REFERENCES Countries (country_id)
); ------making main table

INSERT INTO Locations


SELECT
location_id, street_adress, postal_code, city, state_province, country_id
FROM ext_ Locations;
----inserting into main table
LOAD DATA

INFILE '/u01/app/external/ Departments.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_Departments
FIELDS TERMINATED BY '|'
(
department_id NUMBER ,
department_name CHAR(20) ,
location_id NUMBER)
-------making control file

CREATE table ext_ Departments (


department_id NUMBER,
department_name VARCHAR2(20),
location_id NUMBER
);
--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Departments.ctl


log=/u01/app/ext/ Departments.log bad=/u01/app/ext/ Departments.bad;

------loading data into staging table

CREATE table Departments (


department_id NUMBER NOT NULL,
department_name VARCHAR2(20) Not NULL,
location_id NUMBER NOT NULL,
CONSTRAINT DEPARTMENT_ID_PK PRIMARY KEY (department_id),
CONSTRAINT "LOCATION_ID_FK" FOREIGN KEY (location_id)
REFERENCES Locations (location_id)
);
------making main table

INSERT INTO Departments


SELECT
department_id, department_name, location_id
FROM ext_Departments;
----inserting into main table
LOAD DATA

INFILE '/u01/app/external/ Manager.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_ Manager
FIELDS TERMINATED BY '|'
(
manager_id NUMBER ,
department_id NUMBER)
-------making control file

CREATE table ext_Manager (


manager_id NUMBER,
department_id NUMBER
);
--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Manager.ctl log=/u01/app/ext/


Manager.log bad=/u01/app/ext/ Manager.bad;

------loading data into staging table

CREATE table Manager (


manager_id NUMBER NOT NULL,
department_id NUMBER NOT NULL,
CONSTRAINT MANAGER_ID_PK PRIMARY KEY (manager_id),
CONSTRAINT "DEPARTMENT_ID_FKM" FOREIGN KEY (department_id)
REFERENCES Departments (department_id));
------making main table

INSERT INTO Manager


SELECT
manager_id, department_id
FROM ext_Manager;
----inserting into main table
LOAD DATA

INFILE '/u01/app/external/ Employee.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_Employee
FIELDS TERMINATED BY '|'
(
employee_id NUMBER ,
first_name CHAR(200),
last_name CHAR(200),
email CHAR(200),
phone_number NUMBER ,
hire_date date,
job_id NUMBER ,
salary CHAR (200) ,
commission_pct NUMBER(3,2),
manager_id NUMBER,
department_id NUMBER)
-------making control file

CREATE table ext_ Employee (


employee_id NUMBER NOT NULL,
first_name VARCHAR2(200),
last_name VARCHAR2(200),
email VARCHAR2(200),
phone_number NUMBER,
hire_date date,
job_id NUMBER,
salary VARCHAR2 (200),
commission_pct NUMBER(3,2),
manager_id NUMBER,
department_id NUMBER
);
--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Employee.ctl log=/u01/app/ext/


Employee.log bad=/u01/app/ext/ Employee.bad;

------loading data into staging table

CREATE table Employee (


employee_id NUMBER NOT NULL,
first_name VARCHAR2(200),
last_name VARCHAR2(200),
email VARCHAR2(200),
phone_number NUMBER NOT NULL,
hire_date date,
job_id NUMBER NOT NULL,
salary VARCHAR2 (200) NOT NULL,
commission_pct NUMBER(3,2),
manager_id NUMBER,
department_id NUMBER,
CONSTRAINT EMPLOYEE_ID_PK PRIMARY KEY (employee_id),
CONSTRAINT "JOBS_ID_FK" FOREIGN KEY (job_id)
REFERENCES Jobs (job_id),
CONSTRAINT "MANAGER_ID_FK" FOREIGN KEY (manager_id)
REFERENCES Managers (manager_id),
CONSTRAINT "DEPARTMENT_ID_FKE" FOREIGN KEY (department_id)
REFERENCES Departments (department_id));
------making main table

INSERT INTO Employee


SELECT
employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary,
commission_pct, manager_id, department_id
FROM ext_Employee;
----inserting into main table

LOAD DATA

INFILE '/u01/app/external/ Job_History.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_ Job_History
FIELDS TERMINATED BY '|'
(
employee_id NUMBER ,
start_date date ,
end_date DATE ,
job_id NUMBER ,
department_id NUMBER)
-------making control file

CREATE table ext_ Job_History (


employee_id NUMBER,
start_date date,
end_date DATE,
job_id NUMBER,
department_id NUMBER);

--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Job_History.ctl


log=/u01/app/ext/ Job_History.log bad=/u01/app/ext/ Job_History.bad;

------loading data into staging table

CREATE table Job_History (


employee_id NUMBER NOT NULL,
start_date date NOT NULL,
end_date DATE NOT Null,
job_id NUMBER NOT NULL,
department_id NUMBER NOT NULL,
CONSTRAINT "EMPLOYEE_ID_FKJH" FOREIGN KEY (employee_id)
REFERENCES Employees (employee_id),
CONSTRAINT "JOBS_ID_FKJH" FOREIGN KEY (job_id)
REFERENCES Jobs (job_id),
CONSTRAINT "DEPARTMENT_ID_FKJH" FOREIGN KEY (department_id)
REFERENCES Departments (department_id));
------making main table

INSERT INTO Job_History


SELECT
employee_id, start_date, end_date, job_id, department_id
FROM ext_Job_History;
----inserting into main table

LOAD DATA

INFILE '/u01/app/external/ Warehouse.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_ Warehouse
FIELDS TERMINATED BY '|'
(
warehouse_id NUMBER ,
warehouse_spec CHAR(200) ,
warehouse_name CHAR(200) ,
location_id NUMBER ,
wh_geo_location CHAR(200))
-------making control file
CREATE table ext_Warehouse (
warehouse_id NUMBER NOT NULL,
warehouse_spec VARCHAR2(200),
warehouse_name VARCHAR2(200),
location_id NUMBER,
wh_geo_location VARCHAR2(200)
);
--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Warehouse.ctl log=/u01/app/ext/


Warehouse.log bad=/u01/app/ext/ Warehouse.bad;

------loading data into staging table

CREATE table Warehouse (


warehouse_id NUMBER NOT NULL,
warehouse_spec VARCHAR2(200) NOT NULL,
warehouse_name VARCHAR2(200) NOT NULL,
location_id NUMBER NOT NULL,
wh_geo_location VARCHAR2(200) NOT Null,
CONSTRAINT WAREHOUSE_ID_PK PRIMARY KEY (warehouse_id),
CONSTRAINT "LOCATION_ID_FKWH" FOREIGN KEY (location_id)
REFERENCES Locations (location_id));
------making main table

INSERT INTO Warehouse


SELECT
warehouse_id, warehouse_spec, warehouse_name, location_id, wh_geo_location
FROM ext_Warehouse;
----inserting into main table
LOAD DATA

INFILE '/u01/app/external/ Orders.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_Orders
FIELDS TERMINATED BY '|'
(
order_id NUMBER ,
order_date date ,
order_mode CHAR(200) ,
customer_id NUMBER ,
order_status CHAR(200) ,
order_total NUMBER ,
sales_rep_id NUMBER ,
promotion_id NUMBER)
-------making control file
CREATE table ext_Orders (
order_id NUMBER,
order_date date,
order_mode VARCHAR2(200),
customer_id NUMBER,
order_status VARCHAR2(200),
order_total NUMBER,
sales_rep_id NUMBER,
promotion_id NUMBER
);
--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Orders.ctl log=/u01/app/ext/


Orders.log bad=/u01/app/ext/ Orders.bad;

------loading data into staging table

CREATE table Orders (


order_id NUMBER NOT NULL,
order_date date NOT NULL,
order_mode VARCHAR2(200) NOT NULL,
customer_id NUMBER NOT NULL,
order_status VARCHAR2(200) NOT Null,
order_total NUMBER NOT NULL,
sales_rep_id NUMBER NOT null,
promotion_id NUMBER NOT null,
CONSTRAINT ORDER_ID_PK PRIMARY KEY (order_id),
CONSTRAINT "CUSTOMERS_ID_FK" FOREIGN KEY (customer_id)
REFERENCES Customers (customer_id),
CONSTRAINT "SALES_REP_ID_FK" FOREIGN KEY (sales_rep_id)
REFERENCES Employees (employee_id)
);
------making main table

INSERT INTO Orders


SELECT
order_id, order_date, order_mode, customer_id, order_status, order_total, sales_rep_id, promotion_id
FROM ext_Orders;
----inserting into main table

LOAD DATA

INFILE '/u01/app/external/ Inventories.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_Inventories
FIELDS TERMINATED BY '|'
(
product_id NUMBER ,
warehouse_id NUMBER ,
quantity_on_hand NUMBER
)
-------making control file
CREATE table ext_Inventories (
product_id NUMBER,
warehouse_id NUMBER,
quantity_on_hand NUMBER
);
--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Inventories.ctl log=/u01/app/ext/


Inventories.log bad=/u01/app/ext/ Inventories.bad;

------loading data into staging table

CREATE table Inventories (


product_id NUMBER NOT NULL,
warehouse_id NUMBER NOT NULL,
quantity_on_hand NUMBER NOT NULL,
CONSTRAINT "PRODUCT_ID_FK" FOREIGN KEY (product_id)
REFERENCES Product_Information (product_id),
CONSTRAINT "WAREHOUSE_ID_FK" FOREIGN KEY (warehouse_id)
REFERENCES Warehouse (warehouse_id)
);
------making main table

INSERT INTO Inventories


SELECT
product_id, warehouse_id, quantity_on_hand
FROM ext_Inventories;
----inserting into main table
LOAD DATA

INFILE '/u01/app/external/ Order_Items.txt'


APPEND INTO TABLE SYSTEMADMIN.ext_Order_Items
FIELDS TERMINATED BY '|'
(
product_id NUMBER ,
order_id NUMBER NOT NULL,
line_item_id Number NOT NULL,
product_id NUMBER NOT NULL,
unit_price NUMBER,
quantity NUMBER NOT NULL)
-------making control file
CREATE table ext_Order_Items (
order_id NUMBER,
line_item_id Number,
product_id NUMBER,
unit_price NUMBER,
quantity NUMBER
);
--------making staging table

sqlldr userid=systemadmin/systemadmin12345# control=/u01/app/ext/ Order_Items.ctl


log=/u01/app/ext/ Order_Items.log bad=/u01/app/ext/ Order_Items.bad;

------loading data into staging table

order_id NUMBER NOT NULL,


line_item_id Number NOT NULL,
product_id NUMBER NOT NULL,
unit_price NUMBER,
quantity NUMBER NOT NULL,
CONSTRAINT "ORDER_ID_FK" FOREIGN KEY (order_id)
REFERENCES Orders(order_id),
CONSTRAINT "PRODUCT_ID_FKOI" FOREIGN KEY (product_id)
REFERENCES Product_Information (product_id)
);
------making main table

INSERT INTO Order_Items


SELECT
order_id, line_item_id, product_id, unit_price, quantity
FROM ext_Order_Items;
----inserting into main table
Steps for the installation of Oracle node

Step 1
Step 2

Step 3
Step 4

Step 5 Step 6
Step 7 Step 8

Step 10
Step 9

Step 11 Step 12
Step 13

This code is used to connect with tableau to show the diagrams made in it
Installation of tableau

You might also like