You are on page 1of 3

ASSINGMENT #0 (Fundamental Queries)

Questions #1

Installation of Oracle 19c Rel 3 on your laptop and run the following commands after the
successful installations:

Step 1:

Get the Pluggable database name and service name.


C:\> sqlplus / as sysdba
SQL> SHOW con_name

To find out the name of all the pluggable databases available in your system you can
query v$pbds view.

SQL> SELECT name, con_id FROM v$pdbs;


SQL> SELECT name FROM v$active_services WHERE con_id = 3;

Step 2: Add and Update the following commands in tnsname.ora file located in
ORACLE_HOME/network/admin

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

Step3: Switch the container from CBD$ROOT to PDBORCL


To switch the container first you need to log on to your database using sys user again

C:\> sqlplus / as sysdba

SQL> ALTER SESSION SET CONTAINER = pdborcl;


SQL> SHOW con_name;

Step 4: Open the pluggable database PDBORCL

SQL> SELECT name, open_mode FROM v$pdbs;


SQL> ALTER PLUGGABLE DATABASE open;

Step 5: Unlock the HR user

SQL> ALTER USER hr IDENTIFIED BY hr ACCOUNT unlock;

_______________________________________________________________________
CSF-505-Database Management Dr. Imran Khan
Department of Computer Science – School of Mathematics and Computer Science
Institute of Business Administration
Step 6: Log in to your database using HR user

SQL> conn hr/hr@orclpdb;

Questions #2

a. Download the attachment demobld.sql in c or d drive and run it on Oracle SQL


19c using "@d:\demobld.sql" command

OR

If you are using apex.oracle.com then upload demobld.sql file on your workspace
and run.

b. Use Demobld schema and solve the following queries:

EMP (EMPNO, ENAME, JOB, SAL, HIREDATE, COMM, MGR, DEPTNO)


DEPT (DEPTNO, DNAME, LOC)
SALGRADE (GRADE, LOSAL, HISAL)

1. Display the details of all the employees who are working in the organization.
2. List all the rows from the table SALGRADE.
3. List all the rows from the table DEPT.
4. Display the structure of the table EMP.
5. Display the structure of the table SALGRADE.
6. Display the structure of the table DEPT.
7. List all the tables.
8. What are the employee numbers of all the employees?
9. What are the employee names of all the employees?
10. List all JOBS from EMP.
11. Display the SALARIES of all the employees.
12. How do we get to know, when did all the employees join the company?
13. Is there anyone who is taking commission? If yes then display.
14. Who is the manager of whom?
15. What are the departments of every employee?
16. Display the job designation with their employee number. List all EMPLOYEE
NUMBER, EMPLOYEE NAME, JOB, MGR, SALARY from EMP.
17. List all EMPLOYEE NUMBER, EMPLOYEE NAME, JOB, MGR,
SALARY, HIREDATE, COMMISSION from EMP.
18. List all EMPLOYEE NUMBER, EMPLOYEE NAME, MGR, SALARY,
HIREDATE, COMMISSION, DEPARTMENT NUMBER from EMP.
19. What are the DEPARTMENT NUMBER, JOBS of all the employees?
20. What is the DEPARTMENT NAME and JOB of all the employees?
21. Where are all the departments’ located?
22. What is the department number and department name of all the departments?
23. Display the department number of all the departments with their location and
name.
_______________________________________________________________________
CSF-505-Database Management Dr. Imran Khan
Department of Computer Science – School of Mathematics and Computer Science
Institute of Business Administration
24. List all the GRADES from SALGRADE.
25. List all the LOW-SAL from SALGRADE.
26. List all the HI-SAL from SALGRADE.
27. List all the LOW-SAL, HI-SAL, grade from SALGRADE.

Deliverables:
1. Submit the screenshots of successful installation message of Oracle 19c Rel 3 and
also the screenshot of successful HR user login screen.
2. Submit the spool file of all the commands. (only the successful commands)
e.g. You can create spool file using the following command in Oracle SQL Plus:
SQL>spool d:\queries.sql
OR
If you are using apex.oracle.com then submit the screenshots of the successful
queries with output.

The Instructions
• This is an INDIVIDUAL assignment. Submission in the group is not allowed
• Due Date: 8.00 am Tuesday, 31st August 2021.
• No extensions will be given: Penalties are applied to late submissions (5% of total
assignment mark given is deducted per day, accepted up to 5 days after the due date
only). Note that delays caused by computer downtime cannot be accepted as a valid
reason for late submission without penalty. Students must plan their work to allow for
both scheduled and unscheduled downtime.

_______________________________________________________________________
CSF-505-Database Management Dr. Imran Khan
Department of Computer Science – School of Mathematics and Computer Science
Institute of Business Administration

You might also like