Lec11_240406
Lec11_240406
Database
Administration,
Distribution
and Security
Chapters 12 and 16 - Coronel, C., Morris, S. & Rob, P. (2023). Database Systems: Design, Implementation & Management, 14th
Edition, Cengage Learning
Learning Objectives
11-2
Database Administrator (DBA)’s Managerial
Role
• Provide end-user support
• Enforce policies, procedures, and standards
for correct data creation, usage, and
distribution within the database
• Manage data security, privacy, and integrity
• Manage data backup and recovery
– Fully recover data in case of data loss
– Database security officer (DSO): Ensures database
security and integrity
11-3
A plan that is made for dealing with an emergency
11-4
DBA’s Technical Role
• Evaluate, select, and install DBMS and related
utilities
實施
• Design and implement databases and
applications
• Test and evaluate databases and applications
• Operate the DBMS, utilities, and applications
• Train and support users
• Maintain the DBMS, utilities, and applications
11-5
分散式
Distributed Database
• Distributed database: single logical database
physically divided among networked
computers
• Distributed database management system
操縱
(DDBMS): supports and manipulates
distributed databases
11-6
Distributed Database
11-7
特徵
Characteristics of Distributed DBMSs
同質
• Homogeneous DDBMS: same local DBMS at
each site
異質
• Heterogeneous DDBMS: at least two sites at
which local DBMSs are different (multiple
databases)
• Shared characteristics of DDBMSs
– Location transparency
– Replication
碎片化 transparency
– Fragmentation transparency
11-8
9
威脅
Threats to Computer Systems
The act of getting money from people
by threatening to tell a secret of theirs
11-11
Countermeasures – Computer-Based
Controls
對策 an action taken against an unwanted action or situation
12
11-12
Countermeasures – Computer-Based
Controls
• Authentication
– A mechanism that determines whether a user is
who he or she claims to be.
13
11-13
Countermeasures – Computer-Based
Controls
• Authorization
授予 特權
– The granting of a right or privilege, which enables
a subject to legitimately have access to a system
or a system’s object.
14
11-14
Creating Users
• The DBA creates users by using the CREATE
USER statement.
CREATE USER user
IDENTIFIED BY password;
SQL>
SQL> CREATE
CREATE USER
USER scott
scott
22 IDENTIFIED
IDENTIFIED BY
BY tiger;
tiger;
User
User created.
created.
cresecure.sql
11-15
So, putting it all together, you're telling the database, "Let's set up a new
user called Scott, and his password will be tiger." Once this command is
executed, Scott will have his own user account in the database and can log
in using "tiger" as his password.
16
User System Privileges
• Once a user is created, the DBA can grant specific system privileges
to a user.
GRANT
GRANT privilege
privilege [,
[, privilege...]
privilege...]
TO
TO user
user [,
[, user...];
user...];
11-17
授予
Granting System Privileges
• The DBA can grant a user specific system
privileges.
SQL>
SQL> GRANT
GRANT create
create table,
table, create
create sequence,
sequence, create
create view
view
22 TO
TO scott;
scott;
Grant
Grant succeeded.
succeeded.
11-18
What Is a Role?
11-19
Creating and Granting Privileges to a Role
SQL>
SQL> CREATE
CREATE ROLE
ROLE manager;
manager;
Role
Role created.
created.
SQL>
SQL> GRANT
GRANT create
create table,
table, create
create view
view
22 to
to manager;
manager;
Grant
Grant succeeded.
succeeded.
SQL>
SQL> GRANT
GRANT manager
manager to
to BLAKE,
BLAKE, CLARK;
CLARK;
Grant
Grant succeeded.
succeeded.
11-20
21
22
23
Changing Your Password
– The DBA creates your user account and initializes your
password.
– You can change your password by using the ALTER
USER statement.
– Syntax
ALTER USER user IDENTIFIED BY password;
– where: user is the name of the
user
password specifies the new password
SQL> ALTER USER scott
2 IDENTIFIED BY lion;
User altered.
11-24
Object Privileges
Object
Privilege Table View Sequence Procedure
ALTER
DELETE
EXECUTE
INDEX
INSERT
REFERENCES
SELECT
UPDATE
11-25
26
27
28
29
30
Object Privileges
– Object privileges vary from object to object.
– An owner has all the privileges on the object.
– An owner can give specific privileges on that
owner’s object.
GRANT
GRANT object_priv
object_priv [(columns)]
[(columns)]
ON
ON object
object
TO
TO {user|role|PUBLIC}
{user|role|PUBLIC}
[WITH
[WITH GRANT
GRANT OPTION];
OPTION];
11-31
Granting Object Privileges
– Grant query privileges on the EMP table.
SQL>
SQL> GRANT
GRANT select
select
22 ON
ON emp
emp
33 TO
TO sue,
sue, rich;
rich;
Grant
Grant succeeded.
succeeded.
11-32
Using WITH GRANT OPTION and PUBLIC Keywords
11-34
35
36
37
The CREATE SEQUENCE Statement Syntax
CREATE
CREATE SEQUENCE
SEQUENCE sequence
sequence
[INCREMENT
[INCREMENT BYBY n]
n]
[START
[START WITH
WITH n]
n]
[{MAXVALUE
[{MAXVALUE nn || NOMAXVALUE}]
NOMAXVALUE}]
[{MINVALUE
[{MINVALUE nn || NOMINVALUE}]
NOMINVALUE}]
[{CYCLE
[{CYCLE || NOCYCLE}]
NOCYCLE}]
[{CACHE
[{CACHE nn || NOCACHE}];
NOCACHE}];
11-38
Creating a Sequence
• Create a sequence named DEPTNO_SEQ to be
used for the primary key of the DEPT table.
• Do not use the CYCLE option.
CREATE
CREATE SEQUENCE
SEQUENCE deptno_seq
deptno_seq
INCREMENT
INCREMENT BY
BY 22
START
START WITH
WITH 4242
MAXVALUE
MAXVALUE 80
80
NOCACHE
NOCACHE
NOCYCLE;
NOCYCLE;
Sequence
Sequence created.
created.
creseq.sql
11-39
Using a Sequence
• Insert a new department named “Support” in
loc “Kowloon”.
INSERT
INSERT INTO
INTO dept(deptno,
dept(deptno, dname,
dname, loc)
loc)
VALUES
VALUES (deptno_seq.NEXTVAL,
(deptno_seq.NEXTVAL,
'Support',
'Support', ‘Kowloon');
‘Kowloon');
11 row
row created.
created.
creseq.sql
11-40
Removing a Sequence
• Remove a sequence from the data dictionary by using the
DROP SEQUENCE statement.
• Once removed, the sequence can no longer be referenced.
DROP
DROP SEQUENCE
SEQUENCE dept_deptid_seq;
dept_deptid_seq;
Sequence
Sequence dropped.
dropped.
11-41
Required Privileges
System privileges
Object privileges
Owner grants
EXECUTE
11-42
Granting Access to Data
Direct access:
EMP
GRANT SELECT Scott
ON emp
TO scott;
Grant Succeeded.
SELECT
Indirect access:
GRANT EXECUTE Green
ON query_emp SCOTT.QUERY_EMP
TO green;
Grant Succeeded.
REVOKE
REVOKE {privilege
{privilege [,
[, privilege...]|ALL}
privilege...]|ALL}
ON
ON object
object
FROM
FROM {user[,
{user[, user...]|role|PUBLIC}
user...]|role|PUBLIC}
[CASCADE
[CASCADE CONSTRAINTS];
CONSTRAINTS];
11-44
Revoking Object Privileges
• As user Alice, revoke the SELECT and INSERT
privileges given to user Scott on the DEPT table.
SQL>
SQL> REVOKE
REVOKE select,
select, insert
insert
22 ON
ON dept
dept
33 FROM
FROM scott;
scott;
Revoke
Revoke succeeded.
succeeded.
11-45
Why Use Views?
• To restrict data access
• To make complex queries easy
• To provide data independence
• To present different views of the same data
11-46
Why Use Views?
47
48
49
50
Create the view regardless Create the view only if
Creating a View
of whether or not the the base table(s) exist(s)
base table(s) exist(s)
11-51
Creating a View
• Create a view, EMPVU80, that contains
details of employees in department 30.
CREATE VIEW empvu30
AS SELECT empno, ename, sal
FROM emp
WHERE deptno = 30;
View created.
creview.sql
11-52
53
54
Removing a View
DROP
DROP VIEW
VIEW view;
view;
11-55
Countermeasures – Computer-Based
Controls
• Integrity
– Prevents data from becoming invalid, and hence
giving misleading or incorrect results.
• Encryption
– The encoding of the data by a special algorithm
that renders the data unreadable by any program
without the decryption key.
56
11-56
Countermeasures – Computer-Based
Controls
• Backup
– Process of periodically taking a copy of the
database and log file (and possibly programs) to
offline storage media.
• Journaling
– Process of keeping and maintaining a log file (or
journal) of all changes made to database to enable
effective recovery in event of failure.
57
11-57
Countermeasures – Computer-Based
Controls
• Availabilty
– Ensures that database service is available even in
event of failure.
58
11-58
Oracle Data Guard
Oracle Data Guard is the management, monitoring, and
automation software that works with a production database
and standby database(s) to protect the data against failures,
errors, and corruptions that destroy the production database.
One or more
copies of the
production
database
called
11-59
Switchover and Failover
– Switchover
• Planned role reversal
• Used for operating system or hardware
maintenance
– Failover
• Unplanned role reversal
• Use in emergency
• Minimal or zero data loss depending on
choice of data protection mode
11-60
61
62
Why Oracle Data Guard?
連續的
– Continuous service through a disaster or crippling
data failure 嚴重損壞 seriously damaging
– Complete data protection against corruptions and
data loss
– Get more work done on your production systems
– Eliminate idle standby systems
– Configure the system to meet business protection
and recovery requirements
– Centralized and simple management
11-63
RAID (Redundant Array of Independent
Disks) Technology
• A large disk array comprising an arrangement of several
independent disks having redundant components integrated
into the working system organized to
– improve reliability whenever there is one or more component
failures
– increase performance by ensuring the DBMS continues to operate
even if one of the hardware components fails.
64
11-64