Skip to content

Instantly share code, notes, and snippets.

@anubhavg-icpl
Created December 1, 2024 18:58
Show Gist options
  • Save anubhavg-icpl/c128c4f6f14713d9db911914c59eccb0 to your computer and use it in GitHub Desktop.
Save anubhavg-icpl/c128c4f6f14713d9db911914c59eccb0 to your computer and use it in GitHub Desktop.

Based on the documentation, I'll help guide you through installing Oracle Database Free on Oracle Linux 9. Here are the steps:

  1. First, log in as the root user.

  2. Install the Oracle Database Preinstallation RPM:

dnf -y install oracle-database-preinstall-23ai
  1. Go to the Oracle Database Free software download page: https://www.oracle.com/database/technologies/free-downloads.html

  2. Download this specific RPM file: oracle-database-free-23ai-1.0-1.el9.x86_64.rpm

  3. Install the database software:

dnf -y install oracle-database-free-23ai-1.0-1.el9.x86_64.rpm
  1. After installation, create and configure the database:
    • Log in as root:
    sudo -s
    • Run the configuration script:
    /etc/init.d/oracle-free-23ai configure
    • When prompted, you'll need to set a password for the SYS, SYSTEM, and PDBADMIN accounts
      • Password must be at least 8 characters long
      • Include at least 1 uppercase letter
      • Include at least 1 lowercase letter
      • Include at least 1 digit [0-9]

The installation will:

  • Create a container database named 'FREE'
  • Create a pluggable database named 'FREEPDB1'
  • Configure the listener on the default port (1521)
  • Use approximately 9 GB of disk space under /opt

Important notes:

  • Make sure you have sufficient disk space (at least 9 GB) under /opt
  • The installation doesn't support symbolic links for /opt/oracle
  • If you have any existing Oracle Database XE or Free version with SID 'XE' or 'FREE', you need to uninstall it first

Would you like me to explain any specific part of the installation process in more detail?

Based on the provided information, I'll guide you through the post-installation steps to set up your Oracle Database 23c Free. Here's what you need to do:

  1. First, set up your environment variables. Log in as the Oracle user and run:
export ORACLE_SID=FREE 
export ORAENV_ASK=NO 
. /opt/oracle/product/23ai/dbhomeFree/bin/oraenv
  1. Connect to your pluggable database as SYSDBA:
sqlplus sys@localhost:1521/FREEPDB1 as sysdba

When prompted, enter the password you set during installation.

  1. Once connected, you can set up a sample user and database:
-- Create a new user
CREATE USER sampleuser IDENTIFIED BY "YourStrongPassword123"
QUOTA UNLIMITED ON USERS;

-- Grant necessary privileges
GRANT CREATE SESSION TO sampleuser;
GRANT CREATE TABLE TO sampleuser;
GRANT CREATE VIEW TO sampleuser;
GRANT CREATE SEQUENCE TO sampleuser;
GRANT CREATE PROCEDURE TO sampleuser;
  1. Now you can connect as the new user and create sample tables:
-- Connect as the new user
CONNECT sampleuser/YourStrongPassword123@localhost:1521/FREEPDB1

-- Create sample employees table
CREATE TABLE employees (
    employee_id NUMBER PRIMARY KEY,
    first_name VARCHAR2(50),
    last_name VARCHAR2(50),
    email VARCHAR2(100),
    hire_date DATE,
    salary NUMBER(8,2)
);

-- Create sample departments table
CREATE TABLE departments (
    department_id NUMBER PRIMARY KEY,
    department_name VARCHAR2(100),
    location VARCHAR2(100)
);
  1. Insert some sample data:
-- Insert department data
INSERT INTO departments VALUES (1, 'IT', 'New York');
INSERT INTO departments VALUES (2, 'Sales', 'Chicago');
INSERT INTO departments VALUES (3, 'Marketing', 'Los Angeles');

-- Insert employee data
INSERT INTO employees VALUES (1, 'John', 'Smith', '[email protected]', DATE '2023-01-15', 75000);
INSERT INTO employees VALUES (2, 'Mary', 'Johnson', '[email protected]', DATE '2023-02-20', 65000);
INSERT INTO employees VALUES (3, 'Robert', 'Brown', '[email protected]', DATE '2023-03-10', 70000);

COMMIT;

Important notes:

  • Replace "YourStrongPassword123" with a strong password that meets Oracle's requirements
  • The default listener port is 1521
  • The main container database is named 'FREE'
  • The pluggable database is named 'FREEPDB1'
  • Database files are located in /opt/oracle/oradata/FREE
  • Alert logs are in /opt/oracle/diag/rdbms/free/FREE/trace/alert_FREE.log

Would you like me to explain any specific part in more detail or help you with additional setup tasks?

@shourywardhan
Copy link

It seems you're encountering several issues, mainly related to the EMPLOYEES table not existing, even though the SAMPLEUSER user exists. Let's go through the problems and provide solutions.

1. ORA-00942: "EMPLOYEES" table or view does not exist

The error indicates that the EMPLOYEES table doesn't exist in the SYS schema, which is expected because you likely created the table in the SAMPLEUSER schema (or intended to do so).

Solution:

You need to connect to the correct schema (in this case, the SAMPLEUSER schema) to access the EMPLOYEES table, assuming you created it there.

You can try the following:

  • Connect as SAMPLEUSER:
sqlplus sampleuser/YourStrongPassword123@192.168.1.21:1521/FREEPDB1
  • Check the EMPLOYEES table in SAMPLEUSER schema:
SELECT * FROM employees;

If the table doesn't exist in the SAMPLEUSER schema, you can create it under the correct user by following these steps:

  1. Switch to the SAMPLEUSER schema:
    If you're connected as SYSDBA and want to perform actions on SAMPLEUSER, you'll need to use ALTER SESSION to switch schemas.
ALTER SESSION SET CURRENT_SCHEMA = SAMPLEUSER;
  1. Create the EMPLOYEES table (if it doesn’t already exist):
CREATE TABLE employees (
    employee_id NUMBER PRIMARY KEY,
    first_name VARCHAR2(50),
    last_name VARCHAR2(50),
    email VARCHAR2(100),
    hire_date DATE,
    salary NUMBER(8,2)
);
  1. Insert data into EMPLOYEES:
INSERT INTO employees (employee_id, first_name, last_name, email, hire_date, salary)
VALUES (1, 'John', 'Smith', '[email protected]', DATE '2023-01-15', 75000);

INSERT INTO employees (employee_id, first_name, last_name, email, hire_date, salary)
VALUES (2, 'Mary', 'Johnson', '[email protected]', DATE '2023-02-20', 65000);

INSERT INTO employees (employee_id, first_name, last_name, email, hire_date, salary)
VALUES (3, 'Robert', 'Brown', '[email protected]', DATE '2023-03-10', 70000);

COMMIT;

Once the table is created and populated, you should be able to query it successfully.

2. Error while creating a view: "EMPLOYEES" table does not exist

You encountered the same issue when trying to create a view on the EMPLOYEES table. This is because the view creation is being attempted under the SYS schema, where the EMPLOYEES table doesn't exist.

Solution:

You need to ensure that the view is created in the correct schema (SAMPLEUSER). After connecting to SAMPLEUSER, run the CREATE VIEW command again.

CREATE VIEW employees_view AS
SELECT employee_id, first_name, last_name, email
FROM employees;

3. The sequence EMPLOYEE_SEQ was created successfully

You successfully created the EMPLOYEE_SEQ sequence. You can use this sequence for generating unique employee_id values if needed.

You can check its values with:

SELECT employee_seq.NEXTVAL FROM dual;

Recap of next steps:

  1. Ensure you are connected to the correct schema (SAMPLEUSER), either by logging in directly as that user or by using ALTER SESSION.
  2. Create the EMPLOYEES table under the correct schema if it doesn’t exist.
  3. Insert sample data into the table.
  4. Create the EMPLOYEES_VIEW view and use it to verify the data.

Let me know if you encounter any further issues!

@shourywardhan
Copy link

Remember use ip a and then take the private ip and so do the login like wise
!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment