Unit 5
Unit 5
Creating Users:
You create a database user with the CREATE USER statement. To create
a user, you must have the CREATE USER system privilege. Because it is
a powerful privilege, a DBA or security administrator is normally the
only user who has the CREATE USER system privilege. A newly created
user cannot connect to the database until granted the CREATE SESSION
system privilege.
CREATE USER bela IDENTIFIED BY bela99 DEFAULT
TABLESPACE DBS_space QUOTA 10M ON DBS_space
TEMPORARY TABLESPACE temp_space PROFILE STAFF
PASSWORD EXPIRE;
Alter Users:
Use the ALTER USER statement:
To change the authentication or database resource characteristics of a
database user To permit a proxy server to connect as a client without
authentication
ALTER USER role_name IDENTIFIED BY password REPLACE
prev_password;
Drop Users:
The DROP USER statement is used to remove a user from the
Oracle database and remove all objects owned by that user.
DROP USER user_name [ CASCADE ];
DROP USER SYS CASCADE;
i. GRANT :
Grants a privilege to a user It means that giving authority to other
user by administrator If you are administrator then only you have
authority for grating the other authority to other user Can grant
privilege only if you have been granted that privilege.
Syntax:
GRANT < Object Privileges > ON <ObjectName> TO
<UserName>
[WITH GRANT OPTION];
OBJECT PRIVILEGES:
Each object privilege that is granted authorizes the grantee to
perform some operation on the object. A user can grant all the
privileges or grant only specific object privileges.
The list of object privileges is as follows:
ALTER : Allows the grantee to change the table definition with
the ALTER TABLE command
DELETE : Allows the grantee to remove the records from the
table with the DELETE command
INDEX : Allows the grantee to create an index on the table with
the CREATE INDEX command
INSERT : Allows the grantee to add records to the table with the
INSERT command
SELECT : Allows the grantee to query the table with the SELECT
command
UPDATE : Allows the grantee to modify the records in the tables
with the UPDATE command
GRANT :
Example:
Give the user POLY permission to only view and modify records
in the table Student.
GRANT SELECT, UPDATE ON Student TO POLY;
Grant succeeded.
REVOKE:
The REVOKE statement is used to deny the grant given on an
object. Revokes a privilege from a user It is use to taking off or
remove of authority or say getting back authority from user.
Syntax:
REVOKE < Object Privileges > ON <Object Name> FROM
<Username>;
Example:
All privileges on the table Student have been granted to POLY.
Take back the Delete privilege on the table.
REVOKE DELETE ON Student FROM POLY;
Revoke succeeded.
5.2 Transactions:
Atomicity :
A transaction is a single unit of operation. You either execute it
entirely or do not execute it at all. There cannot be partial execution.
By this, we mean that either the entire transaction takes place at once or
doesn’t happen at all. There is no midway i.e. transactions do not occur
partially. Each transaction is considered as one unit and either runs to
completion or is not executed at all. It involves the following two
operations.
—Abort: If a transaction aborts, changes made to database are
not visible.
—Commit: If a transaction commits, changes made are visible.
Atomicity is also known as the ‘All or nothing rule’.
Suppose T has been executed till Read (Y) and then T’’ starts. As a result ,
interleaving of operations takes place due to which T’’ reads correct value of X
but incorrect value of Y and sum computed by T’’: (X+Y = 50, 000+500=50,
500) is thus not consistent with the sum at end of transaction: T: (X+Y = 50,
000 + 450 = 50, 450). This results in database inconsistency, due to a loss of 50
units. Hence, transactions must take place in isolation and changes should be
visible only after they have been made to the main memory.
Durability :
Database Backup is storage of data that means the copy of the data. It is a
safeguard against unexpected data loss and application errors. It protects the
database against data loss.If the original data is lost, then using the backup it can
reconstructed.
1. Physical Backup
2. Logical Backup
1. Physical backups:- Physical Backups are the backups of the physical files
used in storing and recovering your database, such as data files, control files and
archived redo logs, log files. It is a copy of files storing database information to
some other location, such as disk, some offline storage like magnetic tape.
Physical backups are the foundation of the recovery mechanism in the database.
Physical backup provides the minute details about the transaction and
modification to the database.
Importance of Backups
Type of failure :
A database management system is susceptible to a number of failures.
i. Soft Failure:
Soft failure is the type of failure that causes the loss in volatile
memory of the computer and not in the persistent storage. Here,
the information stored in the non-persistent storage like main
memory, buffers, caches or registers, is lost. They are also known
as system crash.
The various types of soft failures are as follows −
a. Operating system failure.
b. Main memory crash.
c. Transaction failure or abortion.
d. System generated error like integer overflow or divide-by-
zero error.
e. Failure of supporting software.
f. Power failure.
ii. Hard Failure:
A hard failure is the type of failure that causes loss of data in the
persistent or non-volatile storage like disk. Disk failure may cause
corruption of data in some disk blocks or failure of the total disk.
The causes of a hard failure are −
a. Power failure.
b. Faults in media.
c. Read-write malfunction.
d. Corruption of information on the disk.
e. Read/write head crash of disk.
f. Recovery from disk failures can be short, if there is a new,
formatted, and ready-to-use disk on reserve. Otherwise,
duration includes the time it takes to get a purchase order,
buy the disk, and prepare it.
iii. Network Failure:
Network failures are prevalent in distributed or network databases.
These comprises of the errors induced in the database system due
to the distributed nature of the data and transferring data over the
network.
The causes of network failure are as follows –
a. Communication link failure.
b. Network congestion.
c. Information corruption during transfer.
d. Site failures.
e. Network partitioning.
Causes of Database Failures:
A database includes a huge amount of data and transaction. If the system
crashes or failure occurs, then it is very difficult to recover the database.
There are some common causes of failures such as:
1. System Crash
2. Transaction Failure
3. Network Failure
4. Disk Failure
5. Media Failure
Each transaction has ACID property. If we fail to maintain the ACID
properties, it is the failure of the database system.
It is the method of restoring the database to its correct state in the event of a
failure at the time of the transaction or after the end of a process. Earlier, you
have been given the concept of database recovery as a service that should be
provided by all the DBMS for ensuring that the database is dependable and
remains in a consistent state in the presence of failures. In this context,
dependability refers to both the flexibility of the DBMS to various kinds of
failure and its ability to recover from those failures.
Recovery facilities:
Every DBMS should offer the following facilities to help out with
the recovery mechanism:
i. Backup mechanism makes backup copies at a specific interval for
the database.
ii. Logging facilities keep tracing the current state of transactions
and any changes made to the database.
iii. Checkpoint facility allows updates to the database for getting the
latest patches to be made permanent and keep secure from
vulnerability.
iv. Recovery manager allows the database system for restoring the
database to a reliable and steady-state after any failure occurs.