文件名称:
db2数据库入门教程(官方中文版DB2_Express_v9.7)
开发工具:
文件大小: 5mb
下载次数: 0
上传时间: 2010-12-27
详细说明: 最新官方资料 Contents About this book ............................................................................................................... 11 Notices and trademarks ............................................................................................... 11 Who should read this book? ........................................................................................ 12 How is this book structured? ........................................................................................ 12 A book for the co mmunity ............................................................................................ 13 Authors and Contributors ............................................................................................. 14 Acknowledgements ...................................................................................................... 14 Foreword ...................................................................................................................... 15 PART I – OVERVIEW AND SETUP ................................................................................. 17 Chapter 1 – What is DB2 Express-C? ........................................................................... 19 1.1 Free to develop, deploy, and distribute…no limits! ................................................ 20 1.2 Downloading DB2 Express-C ................................................................................ 20 1.3 User assistance and technical support .................................................................. 21 1.4 DB2 servers ........................................................................................................... 21 1.5 DB2 clients and drivers .......................................................................................... 22 1.6 Application development freedom ......................................................................... 23 1.7 DB2 versions versus DB2 editions ........................................................................ 24 1.8 Moving up to another DB2 edition ......................................................................... 25 1.9 Maintenance and updates for DB2 Express-C ...................................................... 25 1.10 Related free software and DB2 components ....................................................... 26 1.10.1 IBM Data Studio ............................................................................................ 26 1.10.4 DB2 Text Search .......................................................................................... 27 1.10.5 WebSphere Application Server – Community Edition .................................. 27 1.11 Summary .............................................................................................................. 27 Chapter 2 – Related features and products ................................................................. 29 2.1 Features included with DB2 Express subscription (FTL) ....................................... 32 2.1.1 Fix packs ......................................................................................................... 32 2.1.2 High Availability Disaster Recovery (HADR) .................................................. 33 2.1.3 Data Replication ............................................................................................. 33 2.2 Features not available with DB2 Express-C .......................................................... 34 2.2.1 Database Partitioning ..................................................................................... 34 2.2.2 Connection Concentrator ................................................................................ 35 2.2.3 Geodetic Extender .......................................................................................... 35 2.2.4 Label-based Access Control (LBAC) .............................................................. 35 2.2.5 Workload Manager (WLM) .............................................................................. 36 2.2.6 Deep compression .......................................................................................... 37 2.2.7 SQL Compatibility ........................................................................................... 38 2.3 Fee-based products that are related to DB2 ......................................................... 39 2.3.1 DB2 Connect .................................................................................................. 39 2.3.2 InfoSphere Federation Server ........................................................................ 40 2.3.3 InfoSphere Replication Server ........................................................................ 41 2.3.4 Optim Development Studio (ODS) ................................................................. 41 2.3.5 Optim Database Administrator (ODA) ............................................................ 42 6 Getting Started with DB2 Express-C 2.4 DB2 Offerings on Amazon Elastic Compute Cloud ............................................... 42 2.5 Summary ................................................................................................................ 42 Chapter 3 – DB2 installation .......................................................................................... 43 3.1 Installation prerequisites ........................................................................................ 43 3.2 Operating system installation authority .................................................................. 43 3.3 Installation wizard .................................................................................................. 44 3.4 Validating your installation ..................................................................................... 51 3.5 Silent Install ............................................................................................................ 53 3.6 Summary ................................................................................................................ 54 3.7 Exercises ............................................................................................................... 54 Chapter 4 – DB2 Environment ....................................................................................... 59 4.1 DB2 configuration .................................................................................................. 68 4.1.1 Environment variables .................................................................................... 69 4.1.2 Database manager configuration file (dbm cfg) ............................................. 69 4.1.3 Database configuration file (db cfg) ................................................................ 72 4.1.4 DB2 profile registry ......................................................................................... 73 4.2 The DB2 Administration Server (deprecated) ........................................................ 74 4.3 Summary ................................................................................................................ 75 4.4 Exercises ............................................................................................................... 75 Chapter 5 – DB2 Tools .................................................................................................... 81 5.1 IBM Data Studio ..................................................................................................... 83 5.2 Control Center (deprecated) .................................................................................. 84 5.2.1 Launching the Control Center ......................................................................... 87 5.3 Command Editor (deprecated) .............................................................................. 88 5.3.1 Launching the Command Editor ..................................................................... 88 5.3.2 Adding a database connection ....................................................................... 89 5.4 SQL Assist Wizard (deprecated) ........................................................................... 90 5.5 Show SQL Button (deprecated) ............................................................................. 91 5.6 Task Center (deprecated) ...................................................................................... 92 5.6.1 The Tools Catalog database (deprecated) ..................................................... 93 5.7 Journal (deprecated) .............................................................................................. 94 5.7.1 Launching the Journal .................................................................................... 96 5.8 Health Monitor (deprecated) .................................................................................. 96 5.8.1 Health Center (deprecated) ............................................................................ 97 5.9 Self-tuning memory manager ................................................................................ 99 5.10 Scripting ............................................................................................................... 99 5.10.1 SQL scripts ................................................................................................... 99 5.10.2 Operating system (shell) scripts ................................................................. 101 5.11 Windows Vista considerations ........................................................................... 102 5.12 Summary ............................................................................................................ 102 5.13 Exercises ........................................................................................................... 102 PART II – LEARNING DB2: DATABASE ADMINISTRATION ..................................... 107 Chapter 6 – DB2 Architecture ...................................................................................... 109 6.1 DB2 process model ............................................................................................. 109 6.2 DB2 memory model ............................................................................................. 111 Contents 7 6.3 DB2 storage model .............................................................................................. 112 6.3.1 Pages and Extents ........................................................................................ 113 6.3.2 Buffer pools ................................................................................................... 113 6.3.3 Table spaces ................................................................................................ 115 6.4 Summary .............................................................................................................. 120 6.5 Exercises ............................................................................................................. 120 Chapter 7 – DB2 Client Connectivity ........................................................................... 125 7.1 DB2 Directories .................................................................................................... 125 7.1.1 System database directory ........................................................................... 125 7.1.2 Local database directory ............................................................................... 126 7.1.3 Node directory .............................................................................................. 126 7.1.4 DCS directory ............................................................................................... 126 7.2 Configuration Assistant (deprecated) .................................................................. 126 7.2.1 Setup required at the server ......................................................................... 127 7.2.2 Setup required at the client ........................................................................... 130 7.2.3 Creating Client and Server Profiles .............................................................. 133 7.3 Summary .............................................................................................................. 137 7.4 Exercises ............................................................................................................. 137 Chapter 8 – Working with Database Objects ............................................................. 141 8.1 Schemas .............................................................................................................. 141 8.2 Public synonyms (or aliases) ............................................................................... 142 8.3 Tables .................................................................................................................. 143 8.3.1 Data Types.................................................................................................... 143 8.3.2 Identity Columns ........................................................................................... 148 8.3.3 Sequence objects ......................................................................................... 148 8.3.4 System catalog tables ................................................................................... 149 8.3.5 Declared global temporary tables (DGTTs) .................................................. 150 8.3.6 Create Global Temporary Tables (CGTTs) .................................................. 152 8.4 Views ................................................................................................................... 152 8.5 Indexes ................................................................................................................ 153 8.5.1 Design Advisor .............................................................................................. 153 8.6 Referential integrity .............................................................................................. 155 8.7 Schema Evolution ................................................................................................ 156 8.8 Summary .............................................................................................................. 157 8.9 Exercises ............................................................................................................. 157 Chapter 9 – Data Movement Utilities ........................................................................... 161 9.1 EXPORT utility ..................................................................................................... 162 9.2 IMPORT utility ...................................................................................................... 163 9.3 LOAD utility .......................................................................................................... 164 9.4 The db2move utility .............................................................................................. 166 9.5 The db2look utility ................................................................................................ 166 9.6 Summary .............................................................................................................. 169 9.7 Exercises ............................................................................................................. 169 Chapter 10 – Database Security .................................................................................. 173 10.1 Authentication .................................................................................................... 174 8 Getting Started with DB2 Express-C 10.2 Authorization ...................................................................................................... 175 10.2.1 Privileges .................................................................................................... 175 10.2.2 Authorities ................................................................................................... 176 10.2.3 Roles ........................................................................................................... 181 10.3 Group privilege considerations .......................................................................... 182 10.4 The PUBLIC group ............................................................................................ 182 10.5 The GRANT and REVOKE statements ............................................................. 182 10.6 Authorization and privilege checking ................................................................. 183 10.7 Extended Security on Windows ......................................................................... 184 10.8 Summary ............................................................................................................ 185 10.9 Exercises ........................................................................................................... 185 Chapter 11 – Backup and Recovery ............................................................................ 191 11.1 Database Logging .............................................................................................. 191 11.2 Types of logs ...................................................................................................... 192 11.3 Types of logging ................................................................................................ 193 11.3.1 Circular logging ........................................................................................... 193 11.3.2 Archive logging ........................................................................................... 194 11.4 Database logging from the Control Center ........................................................ 195 11.5 Logging parameters ........................................................................................... 196 11.6 Database backup ............................................................................................... 197 11.7 Database recovery ............................................................................................. 199 11.7.1 Recovery types ........................................................................................... 199 11.7.2 Database restore ........................................................................................ 200 11.8 Other operations with BACKUP and RESTORE ............................................... 200 11.9 Summary ............................................................................................................ 200 11.10 Exercises ......................................................................................................... 201 Chapter 12 – Maintenance Tasks ................................................................................ 205 12.1 REORG, RUNSTATS, REBIND ......................................................................... 205 12.1.1 The REORG command ............................................................................... 206 12.1.2 The RUNSTATS command ........................................................................ 206 12.1.3 BIND / REBIND ........................................................................................... 207 12.1.4 Maintenance tasks from the Control Center ............................................... 208 12.2 Maintenance Choices ........................................................................................ 209 12.3 Summary ............................................................................................................ 211 12.4 Exercises ........................................................................................................... 211 Chapter 13 – Concurrency and Locking ..................................................................... 215 13.1 Transactions ...................................................................................................... 215 13.2 Concurrency ....................................................................................................... 216 13.3 Problems without concurrency control ............................................................... 217 13.3.1 Lost update ................................................................................................. 217 13.3.2 Uncommitted read ...................................................................................... 218 13.3.3 Non-repeatable read ................................................................................... 219 13.3.4 Phantom read ............................................................................................. 219 13.4 Isolation Levels .................................................................................................. 220 13.4.1 Uncommitted read ...................................................................................... 220 Contents 9 13.4.2 Cursor stability ............................................................................................ 221 13.4.3 Read stability .............................................................................................. 223 13.4.4 Repeatable read ......................................................................................... 223 13.4.5 Comparing isolation levels .......................................................................... 223 13.4.6 Setting the isolation level ............................................................................ 224 13.5 Lock escalation .................................................................................................. 225 13.6 Lock monitoring .................................................................................................. 226 13.7 Lock wait ............................................................................................................ 227 13.8 Deadlock causes and detection ......................................................................... 228 13.9 Concurrency and locking best practices ............................................................ 229 13.10 Summary .......................................................................................................... 231 13.11 Exercises ......................................................................................................... 231 PART III – LEARNING DB2: APPLICATION DEVELOPMENT .................................... 237 Chapter 14 – Introduction to DB2 Application Development ................................... 239 14.1 DB2 Application Development: The big picture ................................................. 239 14.2 Server-side development ................................................................................... 241 14.2.1 Stored Procedures ...................................................................................... 241 14.2.2 User-defined functions ................................................................................ 242 14.2.3 Triggers ....................................................................................................... 242 14.3 Client-side development .................................................................................... 243 14.3.1 Embedded SQL .......................................................................................... 243 14.3.2 Static SQL vs. Dynamic SQL ...................................................................... 244 14.3.3 CLI and ODBC ............................................................................................ 246 14.3.4 JDBC, SQLJ and pureQuery ...................................................................... 249 14.3.5 OLE DB ....................................................................................................... 251 14.3.6 ADO.NET .................................................................................................... 252 14.3.7 PHP ............................................................................................................. 253 14.3.8 Ruby on Rails ............................................................................................. 254 14.3.9 Perl .............................................................................................................. 254 14.3.10 Python ....................................................................................................... 254 14.4 XML and DB2 pureXML ..................................................................................... 255 14.5 Web Services ..................................................................................................... 255 14.6 Administrative APIs ............................................................................................ 257 14.7 Other development ............................................................................................ 257 14.7.1 Working with Microsoft Access and Microsoft Excel .................................. 257 14.8 Development Tools ............................................................................................ 259 14.9 Sample programs ............................................................................................... 259 14.10 Summary .......................................................................................................... 260 Chapter 15 – DB2 pureXML .......................................................................................... 261 15.1 Using XML with databases ................................................................................ 262 15.2 XML databases .................................................................................................. 262 15.2.1 XML-enabled databases ............................................................................. 262 15.2.2 Native XML databases ................................................................................ 263 15.3 XML in DB2 ........................................................................................................ 264 15.3.1 pureXML technology advantages ............................................................... 265 10 Getting Started with DB2 Express-C 15.3.2 XPath basics ............................................................................................... 267 15.3.3 XQuery basics ............................................................................................ 270 15.3.4 Inserting XML documents ........................................................................... 271 15.3.5 Querying XML data ..................................................................................... 274 15.3.6 Joins with SQL/XML ................................................................................... 281 15.3.7 Joins with XQuery ....................................................................................... 282 15.3.8 Update and delete operations .................................................................... 283 15.3.9 XML indexing .............................................................................................. 285 15.4 Working with XML Schemas .............................................................................. 286 15.4.1 Registering your XML Schemas ................................................................. 286 15.4.2 XML Schema validation .............................................................................. 289 15.4.3 Other XML support ..................................................................................... 290 15.6 Summary ............................................................................................................ 291 15.7 Exercises ........................................................................................................... 291 Appendix A – Troubleshooting .................................................................................... 293 A.1 Finding more information about error codes ....................................................... 294 A.2 SQLCODE and SQLSTATE ................................................................................ 294 A.3 DB2 Administration Notification Log .................................................................... 295 A.4 db2diag.log .......................................................................................................... 295 A.5 CLI traces ............................................................................................................ 296 A.6 DB2 Defects and Fixes ........................................................................................ 296 Appendix B – References and Resources .................................................................. 297 B.1 References .......................................................................................................... 297 B.2 Web sites: ............................................................................................................ 297 B.3 Books ................................................................................................................... 298 B.4 Contact emails ..................................................................................................... 299 ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.