Uploaded by Devine Roronoa

000958762aungpyaecomp1638dbma-170717082214

advertisement
DATABASE MANAGEMENT AND ADMINISTATION
Myanmar Computer Co., Ltd.
Course: COMP 1638
B.Sc. Top up Programme
Date: APRIL 2017
A dissertation submitted in partial fulfillment of the requirements for the University of
Greenwich’s Bachelor of Science Degree in Business Information Technology.
Word Count: 2199
Prepared by: AUNG PYAE
Student ID: 000958762
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
COURSE
: BSc (Hons) Business IT
MODULE TITLE
: DATABASE MANAGEMENT AND ADMINISTRATION
ASSIGNMENT TITLE
: Database Management and Administration - Logbook
CANDIDATE NAME
: AUNG PYAE
SUMMITED DATE
: APRIL 2017
Marker’s Comment
:
Moderator’s Comment
:
EXAM CYCLE
CANDIDATE NO
Marks:
: JUNE 2017
: 000958762
Moderated marks:
Final marks:
[2]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
Statement and Confirmation of Own Work
All GREENWICH Education assessed assignments submitted by students must have this
statement as the cover page or it will not be accepted for marking. Please ensure that this
statement is either firmly attached to the cover of the assignment or electronically inserted
into the front of the assignment.
Student Declaration
I have read and understood GREENWICH Education’s Policy on Academic Dishonesty and
Plagiarism.
I am confirmed the following details:
Student ID/Registration Number : 000958762
Name
Centre Name
Module Name
Module Leader
Title of Work
Number of words
: AUNG PYAE
: MCC TRAINING INSTITUTE (YATANARPON)
: DATABASE MANAGEMENT AND ADMINISTRATION
: DAW THEL SEINT AYE, U NYEIN OO
: Database Management and Administration- Logbook
: 2199
I confirm that this is my own work and that I have not plagiarized any part of it. I have also noted
the assessment criteria and pass mark for assignments.
Due Date
: APRIL 2017
Submitted Date
: APRIL 12, 2017
Student Signature
: AUNGPYAE
[3]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
Database Management and Administration - Logbook
CONTENTS
TASK 1 – Instance and architecture ............................................................................................................. 5
TASK 2 – Processes in instance ................................................................................................................... 6
TASK 3 – Table-space management ............................................................................................................ 8
TASK 4 – System privileges and object privileges .................................................................................... 11
TASK 5 – Creating view............................................................................................................................. 12
TASK 6 – Data concurrency ....................................................................................................................... 14
TASK 7 – PL/SQL ...................................................................................................................................... 17
TASK 8 – PL/SQL function ....................................................................................................................... 19
TASK 9 – Flashback database .................................................................................................................... 21
TASK 10 – Logical backup and physical backup ....................................................................................... 22
REFERENCES ........................................................................................................................................... 23
[4]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
TASK 1 – Instance and architecture
Oracle database


Popular and secure database for managing data and control.
Design and deliver data in an open, comprehensive, and unified management approach.
Oracle instance




A set of database background processes and allocation of memory.
The database allocates a memory area when the instance is started. This memory area of
the database is also called System Global Area (SGA) and this can process or starts with
one or background processes in database.
The SGA can use for various purposes, but common of its services are maintaining data
structures used by processes and threats, block the disk on reading of cache data, online
redo log files, store SQL execution plans.
Instance configuration allows for relationships between database and instance. There are
two types of instance configuration in Oracle database; single instance configuration
allows for one to one relationships, one-to-many (1: N) relationships are allowed by
Oracle Real Application Clusters (Oracle RCA).
Oracle database architecture


Oracle database is made with physical and logical structures. Physical structures can see
on the operating system as they stored data on the hard disk. But logical structures are
created by Oracle database and thus they don’t known by operating system.
Physical structure database files consist of the physical files of database and store on disk.
The database contains data files, redo log files (record of changes for recovery), and
control files (synchronise database activities)
[5]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
TASK 2 – Processes in instance
Processes in instance
In Oracle database, every running process of the database is associated related with instance
process. When database system of the server is started or opened, the system global area starts
Oracle processes called instances to manage the data in database and allows access for users.
When starting the database is start on server, start-up states need to choose and the instance is
created on the database. The instance is started by mounting and opening the database normally
as this type of start-up allows users to connect and serve for typical operations.
There are three steps of start-up:
1. Start instance
2. Mount database
3. Open database
The database administrator has only the access to perform the steps of start-up in database. SQL
plus (SQL * Plus) STARTUP command can used to start the instance of Oracle database. First
login to the system with system administration account and can start the instance with various
methods;
NOMOUNT mode starts the instance of database without mounting. At the monitoring stage,
this mode does not allow accessing the database but this start-up mode requires some recovery
options or parameter files for database.
MOUNT mode starts the instance and database but a weakness is that it closed when leaves.
This mode requires control files and need data files or recovery options.
OPEN mode can operate three stages of starting instance, mounting and opening the database
but the weakness is that this mode can done in unrestricted mode and restricted for all users to
allow access. Only database administrators have access to use this mode and this mode needs
data files and redoes log files to start.
After starting an instance, the database is mounted and accessible for users. Instance reads
initialization or server parameters and multiple instances are allowed.
[6]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
[7]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
TASK 3 – Table-space management
Table-space can used by creating new or modifying the existing table-space by adding data file,
set to extend automatically, increase the size of data file and changing status to offline.
Creating a table-space in Oracle Enterprise Manager;


Login as system administrator to the Enterprise Manager and open the Server tap.
Click on the Table-space and the system will show the list of existing table-spaces.
List of example table-spaces in database are shown and click Create button at right corner of the
table to create a new table-space.
[8]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
Name for the new table-space as “INVENTORY” and click Add button at right button of the
page to configure the settings for the new table-space.
Configure the data file for the new table-space with screenshot as shown.




File name: INVENTORY
File size: 70 MB
Increment: 10 MB
Custom value: 120 MB
[9]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
After completing the configuration form, click Continue to create table-space.
Data for the new table-space is set and click OK button to complete the setup.
New table-space, “INVENTORY” is listed in table-space list.
[10]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
TASK 4 – System privileges and object privileges
System privileges



To perform action on object or action on object of particular type.
Allows users to perform certain functions that are dealing with database management or
server.
Objects include many types of database. Example: database tables, views, sequences,
indexes caches.
Object privileges




Allow users to perform certain actions upon database objects.
Object privileges can assign to database objects (tables / views / schema) with CRUD
operations and also assign for procedures, functions and directories.
Object owner has all object privileges and these privileges cannot be revoked.
The object owner can grant the object privileges for other database users.
Differences between system and object privileges



System privileges are the used for to perform actions that operate at particular level, or
access an action on any schema objects. Example: the privileges to create table-spaces or
deleting rows in tables in a database are system privileges.
Object privileges are used to perform actions on user objects in database. Objects include
tables, views, procedures, functions, etc. for granting a particular database user. Example:
granting a particular database user to DELETE/SELECT from particular table.
Object privileges are different from object to object.
[11]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
TASK 5 – Creating view
Steps to create view;





Using the SQL plus, open the terminal create user “AGREEN” by accessing as system
administrator.
Open the terminal and access the SQLPLUS using system admin control.
Create user “AGREEN” in the terminal.
Create session and grant the user “AGREEN” in the terminal.
Grant to select, update access on the user.
Create new user “AGREEN” and grant to access the user in terminal.
Enter the Oracle Enterprise Manager and click Schema tab to select Views. Create a new view
“AGREEN” and complete from with following view creation query code.
SQL query code for view (dept_stats)
[12]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
Complete the form fields with values shown in screenshot and click OK to create new view.
After view creation is success, opens the terminal and enters query code to retrieve view and the
query result will output as show in the screenshot example.
[13]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
TASK 6 – Data concurrency
Data concurrency


All database users has access to use all data on database at the same time.
Each user can see the transactions of own and other users.
The table below shows the example of data concurrency for multiple transactions. Many
transactions occur at the same time of the database.
Uncommitted changes, long running transactions and high locking for unnecessarily can cause
lock conflicts. Lock conflicts prevent multiple user sessions for changing data in database at
same time. It is high level of data concurrency and no lock requires for queries but lock for data
modifications.
[14]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
Data concurrency example
Open two terminals at the same time and using the SQL plus, create a user account at each
terminal. For each user, create session and grant for each user by entering SQL plus command
line. In the screenshot example, two users AUNGPYAE1 and AUNGPYAE2 are created for
data concurrency test.
Creating two users at each terminal and create sessions and grant for each user.
Connect to users and access to select and update for each user.
As the example, update process of one employee data from the employee table is updated and
from user1 and commit after update process is completed. The user2 also update the same data
and the update process is also complete as the user1 entered commit command.
[15]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
As testing, the employee name of employee ID “100” is updated from “Steven” to “Oggy” from
the user1, and the user2 can also update the name “Oggy” to “Jerry” as the user1 entered commit
command after update process.
As another testing, two users update the same data without commit command and the system
failed to update the process. Without entering commit command, retrieve updated data from
user2 (AUNGPYAE2) and that shows there are no changes on the view of user2.
As testing, the users1 update the salary of employee ID “110” from “10000” to “12000” and not
close the process without entering commit command. The update process is competed for user1
but failed to update from user2 for doing the same process as the user1 forgive to enter commit
command.
The data concurrency process occurs on user 2 because the user 1 updates the data without
commit.
[16]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
TASK 7 – PL/SQL
Creating the new anonymous PL/SQL block that displays on the screen with the following
reports in the view;




the total number of employees in the company
the average salary
the maximum salary
the minimum salary
First open the Oracle system and start the database system. Open the Oracle SQL Developer
application to create a new database connection.
Complete the connection form with connection name, username, password and SID to create
new database connection and click Test button to check connection. If connection is OK, click
Connect to connect with database.
Write the following PL/SQL for output.
[17]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
The PL/SQL codes explains the first the output variables are declare for new variable and after
running the query , they are replaced with selected variables. After setting up the query, the
results are output with their variable values.
Enter the SQL query in the query editor and run the query. The output will result with the total
number of employees, the average salary, the maximum salary and the minimum salary.
[18]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
TASK 8 – PL/SQL function
Creating PL/SQL function
Login to the enterprise manager and click the Schema tab and open Functions in Programs
collection. Clicks create button to create a new function.
Name for the new function and select Schema to place for the new function. Write the SQL code
to produce function and click OK to proceed.
SQL code for new function;
[19]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
After clicking OK button, the new function (GET_ANNUAL_INCOME_AP) will created
successfully with valid status. Open the terminal and enter the SQL command to call function
with SQLPLUS.
[20]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
TASK 9 – Flashback database
Flashback database
Oracle database has features for viewing past (last) data, winding backup of data, reverse the
unwanted changes. These collections of features are called Flashback technology and used when
logical corruption occurs in database or recover data quickly without requiring restore from
backup.
Flashback database uses point-in-time recovery technique for faster restore operation as the time
need to perform. But the time range for process of flashback database backup system depends on
the size of the backup database.
Benefits of flashback database






Reverse the effects of drop table operation.
Rewinds the data records in the table to a specified point by using a single statement.
Returns the database to its last (previous) time to correct (correct) problems with logical
data corruption and user errors.Can used to query all data at desired point of time.
All rows data from the table are exist between two points at desired time by retrieving
data.
Unlimited amount of database space are allocated.
Dropped object can remain in the system recycle for a long time by depending upon the
system activities.
Drawbacks of flashback database





Flashback database uses flash recovery area and depending upon the database size.
If the database size is large, workloads can reduce flash recovery area.
Due to security considerations, the tables of fine-grained audit (FGA) and virtual
proprietary database (VPD) policies defined on them are not protected by the Recycle
Bin.
Flashback databases can only undo the data-files made by Oracle database.
If the database control file is restored or rebuilt from a backup, you cannot use the
Flashback Database to return to a point in time before restarting or rebuilding the control
file.
[21]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
TASK 10 – Logical backup and physical backup
Differences between logical backup and physical backup with benefits and drawbacks
Logical backup







Logical backup of the database system contains logical data from data-files such as tables
and stored procedures.
Exported logical backups are stored in a binary file so that the user can import them back
into the database later using the corresponding import utility.
The export records can read independently with their related physical location.
Export file contains necessary commands for re-creation of selected objects and data.
Data are imported by using Data Pump Import utility system.
Perform the full backup for all data-files on the database system.
Logical backup system is useful supplement for physical backup system.
Physical backup






Physical (real) files, such as text files, are stored as a single document on the hard drive.
Because the database is made up of many complex elements, files are typically
aggregated into simple files on the server's hard drive.
This file can be easily backed up like any other file on the system.
The operating system stores the database files on tape or other media. This is useful for
recalling the system to an earlier point in time as needed.
A physical backup involves copying files (data files, control files, archives, and redo log
files) from the database.The physical backup system is the default backup strategy for the
database.
A physical backup system backup backs up all files in the database system.
[22]
COMP 1638 – DATABASE MANAGEMENT AND ADMINISTRATION
REFERENCES



Ali, "Less04 Instance". Slideshare.net. N.p., 2017. Web. 10 Apr. 2017.
"Difference between Oracle Instance and Oracle Database". Expert Oracle. N.p., 2017.
Web. 10 Apr. 2017.
Relational database (2016) in Wikipedia. (Accessed: 20 November 2016).In-line
Citation:(Relational database, 2016)
● END OF LOGBOOK ●
[23]
Download