DB2 UDB For UNIX, Windows, OS/2 Database Administration Certification Preparation
DB2 UDB For UNIX, Windows, OS/2 Database Administration Certification Preparation
DB2 UDB For UNIX, Windows, OS/2 Database Administration Certification Preparation
We look at the first couple in this overview.... let's start with the Control Center ...
4
Fundamentals
What does the Control Center look like
All SQL statements issued from the Command Line Processor are dynamically prepared and executed on the database server. The output, or result, of the SQL query is displayed on the screen by default. Has is own set of options settings ... you tailor your environment. Know the GUI tools and what each can do for you ... now lets move on to instances and security...
10
The DB2 Administration Server instance will: Obtain the configuration of the operating system Obtain user and group information Start/Stop DB2 instances Set up communications for a DB2 server instance Attach to an instance to perform administration tasks for a database Provide a mechanism to return information about the DB2 servers to remote clients Collect information results from DB2 Discovery The DB2 Administration Server instance will not: Support databases
11
Instance 1
catalog
DB_1
DB config file_1
Instance 2
catalog
DB_3
DB config file_3
log
log
catalog
DB_2
DB config file_2
catalog
DB_4
log
log
DB config file_14
DBM config 1
DBM config 2
13
14
DBADM
Can see or access database
LOAD
PRIVILEGES on db
15
db2 update dbm cfg using sysadm_group adm1 db2 update dbm cfg using sysctrl_group ctrl1 db2 update dbm cfg using sysmaint_group maint1
P r iv i l e g e s
C O N T R O L ( V ie w s )
(S c h e m a) O w ners)
16
Implicit Privileges db2 connect to eddb db2 grant dbadm on database to user fred db2 revoke dbadm on database from user fred What privileges does fred retain? Special group: PUBLIC All users belong to this group Has certain implicit privileges against a database Unique role in package preparation DCL (Data Control Language) Used to provide data object access control GRANT/REVOKE
18
Bob - End user who executes a program app1 and use a table to track personal addresses
NEEDS
DBADM on the database or LOAD authority SYSADM for the instance
EXECUTE on package BINDADD on database CONTROL on table access to req'd objects SELECT, INSERT, UPDATE bob.personal DELETE on various tables
Lock List
Database 1
Catalog Logs
Database 2
Catalog
Logs
DB config file
Index2
Table spaces
DDL (Data Definition Language) Used to create, modify, or drop database objects.
21
Double Byte
Binary String
BLOB
User Defined Types Need to establish context for values DB2 enforced typing IDENTITY Columns
22
You can DECLARE a TEMPORARY table to be used during the connection. But you can only ALTER:
DEPTNAME
MGRNO
Insert Rules Rule is implicit, backout if not found Delete Rules Restrict Cascade No Action Set Null Update Rules Restrict No Action
EMPLOYEE table (Dependent table) EMPNO (Primary key) FIRSTNAME LASTNAME WORKDEPT (Foreign key) PHONENO
25
26
Runtime Client
Manual Configuration
Catalog NODE
catalog tcpip node mynode remote server1 server 50000 catalog netbios node jeremy remote N01FCBE3 adapter 0 catalog npipe node mynode remote jeremy instance db2 catalog ipxspx node mynode remote * server 00000001.08005AB80EE4.879E catalog appc node mynode remote db2cpic00 security same
Catalog DATABASE
catalog database sample as mysamp at node mynode
CONDITIONING
Allows new data to be modified/conditioned to a predefined value.
INTEGRITY
Similar to RI but more flexible
30
31
Table1
Table2
Inner Join
person
oid
name
birth year
oid
name
birth year
salary
oid
name
birth year
major
archivm
33
Check constraints
Check constraints are enforced at any level of a Type Hierarchy regardless where they were defined
RI constraints are not supported for Typed Tables Triggers are not supported for Typed Tables Typed Tables can not be loaded Replication of Typed Tables is not supported Considerations for dropping the table(s)
34
35
Locking Controlled by Isolation Level DB2 provides different levels of protection to Isolate the data.
Uncommitted Read Cursor Stability Read Stability Repeatable Read
For embedded SQL the level is set at bind time For dynamic SQL the level is set at run time Default is Cursor Stability Different types of locks, what you can lock on, how many and how long
36
37
Locks on any row touched in a unit of work. It is the default for applications. Cannot return uncommitted data. Non-repeatable Read and Phantom reads may occur when using this level.
38
39
40
Lock Issues
Lock Waits/Timeouts Deadlocks
41
BUT! ... you knew there had to be one ... no ALTER, COMMENT, GRANT, LOCK, RENAME or REVOKE ability or IMPORT/LOAD and of course do not forget that you need a USER TEMPORARY TABLE SPACE defined.
42
Database Concurrency
Declared Temporary Tables YES there is more!
If you issues a ROLLBACK stmt for a transactions which contains a TEMPORARY table declaration ... that table is dropped. If you issue a DROP TABLE statement for a TEMPORARY table declaration, a ROLLBACK statement only restores the table as an empty table. When you COMMIT the transaction, the default behavior is to DELETE all rows in the table.
avoidance? ... "ON COMMIT PRESERVE ROWS" option on create
OH BOY! If you attempt to modify the table contents using INSERT/UPDATE/DELETE and you do a ROLLBACK or one of the statements fails, all rows are deleted!
43
Database Concurrency
Controlling Transactions with Savepoints
Savepoint? A mechanism of undoing work by DB2 when a database request fails. Savepoint? Makes non-atomic db requests behave atomically. Error occurs during execution? Savepoint can be used to undo changes made by the transaction between the time of the savepoint and the time the savepoint rollback is requested. Similar to a compound SQL statement.
44
Questions? That was just the beginning ... Lets move on to Database Administration ...
45
Database Administration
The sections we are going to be covering for the Database Administration component today include: DB2 Server Management - This is next Data Placement Database Access
Database Recovery and Maintenance Monitoring DB2 Activity and Problem Determination
So as you can see we have a lot to go through...
46
Instance 1
catalog
DB_1
DB config file_1
Instance 2
catalog
DB_3
DB config file_3
log
log
catalog
DB_2
DB config file_2
catalog
DB_4
log
log
DB config file_14
DBM config 1
DBM config 2
47
48
49
Authorities in DB2 provide a hierarchy for administration capabilities as we saw earlier. Authorities are assigned to a group of users. Exceptions to this rule include the DBADM and LOAD authority since they can be granted to a user or a group. If a certain authority is given to a group, each member of that group has the same DB2 authority unless they have had that authority revoked explicitly. The LOAD authority was introduced in DB2 UDB Version 7.1. This allows database administrators to grant authority to users or developers for bulk loading of data into DB2, without requiring them to have DBA capabilities.... we covered this in more detail in the Fundamentals piece today.
50
51
52
53
54
Manual Configuration
Client Configuration Assistant DB2 commands to catalog
55
Database Administration
The sections we are going to be covering for the Database Administration component today include: DB2 Server Management - DONE Data Placement - This is next Database Access
Database Recovery and Maintenance Monitoring DB2 Activity and Problem Determination
56
57
DB2 V7.1 supports system temporary table spaces and user temporary table spaces. A system temporary table space must exist for DB2 to operate properly. User temporary table spaces can be used to place temporary tables.
Table space composed of one or more containers. Data allocated by extents within containers. Three table spaces created by default (all SMS)
SYSCATSPACE - system catalog tables. USERSPACE1 - default user data. TEMPSPACE1 - temporary data.
58
page 0 2
Container 1
Extent
Table space B
New containers cannot be added dynamically unless doing a redirected restore UNIX: file system size may be increased Very easy to administer
61
/mydir1/*
T2.1 T2.3 T2.5 T2.7 T2.9
/mydir2/*
T2.0 T2.2 T2.4 T2.6 T2.8
62
Data "objects" (i.e. table data, indexes, LONG VARCHARs) located by operating system file name. Cannot separate data, index and large object data.
Associate each container (i.e. directory) with a different file system ... otherwise table space capacity limited to that of a single file system Ensure containers have equal capacity (roughly) ... excess in larger containers isn't exploited
63
64
Data striped across containers by extent. Disk space allocated at tablespace creation.
Space Map Pages (SMP) keep track of what extends are used and which are free.
65
0 1 2 3 4 5 6 7 8
Object Table Extent Map for T1 First Extents of Data Pages for T1 Extent Map for T2 First Extent of Data Pages for T2 Another Extent of Data Pages for T1 Second SMP Extent
31968
/myfile /dev/rhd7
66
DMS
Yes DB2 (Object table and EMP extents) Preallocated Good
. Some tuning required (e.g.. EXTENTSIZE PREFETCHSIZE) . Can enlarge table space
Very Good
Best
. Can achieve up to 5-10% advantage with raw containers. . Index, LOBs, Data for a single table can be spanned across table spaces.
Performance
Table spaces can now be renamed which gives ease of movement . Does not include SYSCATSPACE. NOTE: renaming does update the minimum recovery time.
67
68
69
71
Container Definition
Intel: create tablespace enterprise managed by system using ('E:\db\firstcnt', 'F:\db\sndcnt', 'G:\thirdcnt')
72
Container Definition
73
Extended Storage
Synchronous read
Application
Asynchronous read
I/O Prefetchers
74
4K
Synchronous Read
Prefetch Read
I/O Server Data access is faster
I/O Server
Prefetch Read