Professional Documents
Culture Documents
6th-sem-DBA-report[1]
6th-sem-DBA-report[1]
International College
Tribhuvan University
Minbhawan,Kathmandu,Nepal
Submitted By
Name: Rabina Ghimire
Submitted To
V.S. International College
Department of Bachelor in Computer Applications
Minbhawan,Kathmandu,Nepal
Additionally, I extend my thanks to all the lecturers who provided me with essential
advice and knowledge, which proved vital in the development of the project.
Your Sincerely ,
Rabina Ghimire
Table Of Contents
Introduction to Oracle___________________________________________________________4
Architecture of Oracle Database___________________________________________________4
Installation of Oracle Database 19c________________________________________________6
Managing Users, Roles and Privileges_____________________________________________11
Introduction to Oracle
Oracle Corporation is a multinational computer technology corporation that specializes in developing and
selling database software and technology, cloud-engineered systems, and enterprise software products.
One of its flagship products is the Oracle Database, a relational database management system (RDBMS).
This is a high-level overview, and Oracle Database architecture can be quite complex, with many
additional features and components depending on the version and edition of the Oracle Database being
used..
Step 7: Summary
The Summary window shows your previous selections. Once reviewed, select Install to proceed.
Figure 6 Summary
Step 9: Finish
The Finish window shows your Oracle Database registration was successful. Click Close.
Figure 7 Finish
Managing Users, Roles and Privileges
1. Assigning Quotas to Users
Quotas in Oracle Database refer to the amount of space allocated to a user for storing
objects in a specific tablespace.
To assign quotas to users, you can use the ALTER USER statement with the QUOTA
clause, specifying the tablespace and the amount of space. It's a way to manage and
control storage in the database.
Example:
a) Connect to the Database:
Use a SQL*Plus session or another SQL client to connect to your Oracle database using a
privileged account (e.g., SYS or SYSTEM).
Example
ALTER USER john_doe QUOTA 50M ON users_tablespace;
This command allows the user "john_doe" to use up to 50 megabytes of space in the
"users_tablespace."
● Create Users
Let's say you have two users, user_employee and user_manager.
-- Create Employee User
CREATE USER user_employee IDENTIFIED BY password_employee;
-- Create Manager User
CREATE USER user_manager IDENTIFIED BY password_manager;
● Create Roles
Create roles to group related privileges. In this example, we create role_employee for
employee-related privileges and role_manager for manager-related privileges.
-- Create Employee Role
CREATE ROLE role_employee;
-- Create Manager Role
CREATE ROLE role_manager;
● ADMIN_USER:
Tasks: Perform maintenance tasks, create tables, and manage user accounts. Privileges:
DBA role for administrative tasks.
CREATE TABLE for creating tables.
CREATE USER for managing user accounts.
-- Granting privileges to ADMIN_USER
GRANT DBA TO ADMIN_USER;
GRANT CREATE TABLE TO ADMIN_USER;
GRANT CREATE USER TO ADMIN_USER;
Benefits of Applying POLP in Oracle:
Minimizes Security Risks: Users have the minimum privileges required to perform their tasks,
reducing the risk of unauthorized access or data breaches.
Easier Auditing and Monitoring: With fewer privileges, it's easier to monitor and audit user
activities. Suspicious or unauthorized actions can be identified more quickly.
Improved System Stability: Users are less likely to unintentionally interfere with other parts of
the
system since they only have access to the specific resources they need.
3. Creating and Assigning Profiles
In Oracle Database, user accounts are created and managed through profiles. A profile is a set of
resource limits and password policies that can be assigned to users. Profiles help in controlling
and managing the resources that a user can consume and enforce security policies.
Here's an example of creating and assigning profiles in Oracle:
● Creating a Profile:
-- Creating a profile named "custom_profile"
CREATE PROFILE custom_profile
LIMIT
SESSIONS_PER_USER UNLIMITED
CPU_PER_SESSION UNLIMITED
CPU_PER_CALL UNLIMITED
CONNECT_TIME 360
IDLE_TIME 60
LOGICAL_READS_PER_SESSION DEFAULT
LOGICAL_READS_PER_CALL UNLIMITED
COMPOSITE_LIMIT UNLIMITED
PRIVATE_SGA UNLIMITED
FAILED_LOGIN_ATTEMPTS 3
PASSWORD_LIFE_TIME 90
PASSWORD_REUSE_TIME UNLIMITED
PASSWORD_REUSE_MAX UNLIMITED
PASSWORD_LOCK_TIME 1
PASSWORD_GRACE_TIME 7;
This example creates a profile named "custom_profile" with various resource limits and password
policies.
External Authentication:
External authentication allows Oracle to rely on an external service, such as the operating system
or a third-party authentication service. Users are authenticated using credentials provided by the
external service.
Example (Operating System Authentication):
CREATE USER username
IDENTIFIED EXTERNALLY;
LDAP Authentication: Oracle supports Lightweight Directory Access Protocol (LDAP) for
authentication. Users are authenticated against an LDAP directory.
Example:
CREATE USER username IDENTIFIED GLOBALLY AS
'cn=username,dc=example,dc=com';
Network Authentication: Oracle supports secure network protocols such as Secure Sockets
Layer (SSL) and Transport Layer Security (TLS) for secure communication between the client
and
the database. This enhances the security of authentication and data transmission.
Example (Configuring SSL/TLS): ALTER SYSTEM SET
SECURE_SOCKET_LAYER=TRUE;
Lab 2:
Create database examdb and prepare a following table.
1.a. WAQ to add primary key with constraint in a field called emp_id ;
1.b. WAQ to modify the length of a field emp_name varchar(25);
1.c. WAQ to rename the name of the column department to department_name
1.d WAQ to insert the following records in a table.
•(2,'Narayan KShrestha','Politics','10/15/1965','N','Politician','10/25/1999',500000),
•(3,'Sonu Nigam','Music','10/15/1969','N','Singer','10/25/1985',5000000),
•(4,'Dr. Upendra Devkota','Health','10/15/1955','Y','Doctor','10/25/1977',500000),
•(5,'Dr. A. Kalam ','Science','10/15/1945','N','Scientist','10/25/1969',50000000),
•(6,'Dr. Bhola Rijal','Health','10/15/1960','N','Doctor','10/25/1989',400000),
•(7,'Mahabir Pun','Science','10/15/1965','Y','Scientist','10/25/2009',500000);
Solution:
1. create table employee (emp_ id int not null, emp_ name varchar(15), Department varchar(20),
DOB date, Marital_ status char(1), Job title varchar(15), Hiredate date, salary float);
soln
CREATE TABLE employee (
emp_id INT NOT NULL,
emp_name varchar(20),
Department VARCHAR2(20),
Dob DATE,
Marital_status CHAR(1),
Job_title VARCHAR2(15),
Hiredate DATE,
salary FLOAT
);
Output:
1.a. WAQ to add primary key with constraint in a field called emp_ id .
Output:
Output:
UPDATE EMPLOYEE
SET gender = 'female'
WHERE emp_id in (2,7);
Output:
Output:
4.Find the annual salary of the employees and show with their names and id.
Output:
Lab 3:
Create a database called exam_dbase and prepare the following table and insert the following
records;
2.WAQ to show the name and salary who is getting max salary.
3.WAQ to count the number of employees who is getting salary less than avg.
4.WAQ to show the list of the employee's salary in reverse(descending)order
5.WAQ to show the maximum salary.
6.WAQ to show the name and address of the employee who is getting minimum salary.
7.WAQ to show the Total salary.
8.WAQ to show the name and salary of the employee who is getting maximum salary.
9.WAQ to display the total number of employee.
2.WAQ to show the name and salary who is getting max salary.
SELECT emp_names, emp_salary
FROM employedpeople
WHERE emp_salary = (SELECT MAX(emp_salary) FROM employedpeople);
Output:
3.WAQ to count the number of employees who is getting salary less than avg.
SELECT COUNT (*)
FROM employedpeople WHERE emp_salary < (SELECT AVG(emp_salary)
FROM employedpeople);
Output
Output:
Output:
6.WAQ to show the name and address of the employee who is getting minimum salary.
Output:
SELECT SUM(emp_salary)
FROM employedpeople
Output:
8.WAQ to show the name and salary of the employee who is getting maximum salary.
SELECT COUNT(*)
FROM employedpeople;
Output:
Lab 3:
Write DDL commands for following:
a. Create the table named emp having fields (emp_id, name, address DOB, salary)
b. Add primary key and check constraints in the salary fields, value of salary >10000
c. Rename the table emp to employee
d. Insert some rows and delete one of the record from the table employee
e. Create the logical backup of above table using expdp utility
f. Give select,update privilege to another user RAM.
g. Add department_id field as foreign key referencing the table department.
h. Modify the name field to increase the character length and rename the field to ename.
a. Create the table named emp having fields (emp_id, name, address DOB, salary)
CREATE TABLE tbl_employees(
emp_id INT PRIMARY KEY,
emp_name VARCHAR(50),
address VARCHAR(100),
DOB DATE,
salary DECIMAL(10,2)
);
Output: