ORACLG Oracle Press Oracle Database 12c Install, Configure & Maintain Like a Professional Ian Abramson Michael Abbey Michelle Malcher Michael Corey Mc Graw Hill Education New York Chicago San Francisco Athens London Madrid Mexico City Milan New Delhi Singapore Sydney Toronto
[Contents m I ACKNOWLEDGMENTS INTRODUCTION xxi xxiii I The Database: The Foundations of 12c I CRITICAL SKILL 1.1 Define a Database 3 CRITICAL SKILL 1.2 Become Familiar with the Characteristics of a Database 5 Sharing 5 Storage 6 Data Consistency 7 Data Integrity 9 CRITICAL SKILL 1.3 Learn When to Use a Database 12 CRITICAL SKILL 1.4 Learn the Oracle Database 12c Architecture 13 Shared Memory 13 System Support Processes 15 Operating System Files 16 CRITICAL SKILL 1.5 Work with Objects in the Oracle Database 18 Tables 19 Views 20 Synonyms 20 Stored Objects 21 CRITICAL SKILL 1.6 Work with Data Types in an Oracle Database 23... Variable Length Character varchar2 23 Number 24 Datetime 25 CLOB/BLOB 26 CRITICAL SKILL 1.7 Pull It All Together: Objects and Data Types 27 CRITICAL SKILL 1.8 Interact with the Data 30 SQL*Developer 30 sqlplus 34 xi
xii Oracle Database 12c: Install, Configure & Maintain Like a Professional CRITICAL SKILL 1.9 Learn the New Features of Oracle Database 12c 39 Pluggable Databases 40 Application Development 42 Availability 42 Business Intelligence and Data Warehousing 43 Compression and Archiving 44 Overall Database Features 44 Grid Features 44 Manageability 45 Performance 4^ Security XML DB 47 2 Installing Oracle 49 CRITICAL SKILL 2.1 Research and Plan the Installation 50 Define System Requirements 51 Linux Installation 52 CRITICAL SKILL 2.2 Set Up the Operating System 56 Project 2-1 Configure Kernel Parameters 59 Step by Step 59 Project Summary 61 CRITICAL SKILL 2.3 Get Familiar with Linux 61 CRITICAL SKILL 2.4 Choose Components to Install 63 CRITICAL SKILL 2.5 Install the Oracle Software 64 Database Configuration Assistant 73 Verify the Installation 84 Tie It All Together 85 3 SQL: Accessing and Retrieving Data 87 CRITICAL SKILL 3.1 Learn the SQL Statement Components 88 DDL 89 DML 90 CRITICAL SKILL 3.2 Use Basic Insert and Select Statements 91 Insert 91 Select 92 CRITICAL SKILL 3.3 Use Simple WHERE Clauses 94 A WHERE Clause with AND/OR 97 The WHERE Clause with NOT 98 The WHERE Clause with a Range Search 99 The WHERE Clause with a Search List 99 The WHERE Clause with a Pattern Search 100 The WHERE Clause: Common Operators 103 4^
Contents xiii CRITICAL SKILL 3.4 Use Basic Update, Delete, and Merge Statements 105 Update 105 Delete 106 Insert 107 Use Basic Merge Statements 107 CRITICAL SKILL 3.5 Order Data 110 CRITICAL SKILL 3.6 Employ Functions: String, Numeric, Aggregate (No Grouping) 112 String Functions 112 Numeric Functions 113 Aggregate Functions 114 CRITICAL SKILL 3.7 Use Dates and Data Functions (Formatting and Chronological) 115 Date Functions 116 Special Formats with the Date Data Type 116 Nested Functions 116 CRITICAL SKILL 3.8 Employ Joins (ANSI vs. Oracle): Inner, Outer, Self, Apply 119 Inner Joins 119 Outer Joins 124 Project 3-1 Join Data Using Inner and Outer Joins 124 Step by Step 125 Project Summary 127 Project 3-2 Join Data Using ANSI SQL Joins 128 Step by Step 128 Project Summary 129 Self-Joins 129 CRITICAL SKILL 3.9 Learn the Group By and Having Clauses 131 Group By 131 Having 132 Project 3-3 Group Data in Your Select Statements 133 Step by Step 133 Project Summary 135 CRITICAL SKILL 3.10 Learn Subqueries: Simple and Correlated Comparison with Joins 136 Simple Subquery 136 Correlated Subqueries with Joins 137 CRITICAL SKILL 3.11 Use Set Operators: Union, Intersect, Minus 138 Union 139 Union All 140 Intersect 140 Minus 141
1 xiv Oracle Database 12c: Install, Configure & Maintain Like a Professional Project 3-4 Use the Union Function in Your SQL 141 Step by Step 141 Project Summary 142 CRITICAL SKILL 3.12 Use Views 143 CRITICAL SKILL 3.13 Learn Sequences: Just Simple CRITICAL SKILL 3.14 Employ Constraints: Linkage to Entity Models, Stuff 145 Types, Deferred, Enforced, Gathering Exceptions 146 Linkage to Entity Models 147 Types 147 Deferred 149 CRITICAL SKILL 3.15 Format Your Output with SQL*Plus 149 Page and Line Size 149 Page Titles 150 Page Footers 150 Formatting Columns 150 Project 3-5 Format Your SQL Output 150 Step by Step 150 Project Summary 153 Writing SQL*Plus Output to a File 153 4 Programming in the Database 155 CRITICAL SKILL 4.1 Define PL/SQL and Learn Why We Use It 157 CRITICAL SKILL 4.2 Describe the Basic PL/SQL Program Structure... CRITICAL SKILL 4.3 Define PL/SQL Data Types 160 Valid Characters Arithmetic Operators 161 The VARCHAR2 Data Type 163 The NUMBER Data Type 164 The DATE Data Type 164 The BOOLEAN Data Type 165 The VARRAY Data Type 166 CRITICAL SKILL 4.4 Write PL/SQL Programs in SQL*Plus 169 Project 4-1 Create a PL/SQL Program 171 Step by Step 171 Project Summary 171 SQL in Your PL/SQL Programs 172 PL/SQL Cursors 172 The Cursor FOR Loop 1 75 CRITICAL SKILL 4.5 Handle Error Conditions in PL/SQL 1 77 CRITICAL SKILL 4.6 Include Conditions in Your Programs 184 Program Control IF Logic Structures CASE Statements 59 160 184 184 188
Contents XV Loops 189 The WHILE Loop 190 The FOR Loop 190 Project 4-2 Use Conditions and Loops in PL/SQL 192 Step by Step 192 Project Summary 193 CRITICAL SKILL 4.7 Create Stored Procedures How and Why 194 CRITICAL SKILL 4.8 Create and Use Functions 199 Project 4-3 Create and Use a Function 199 Step by Step 200 Project Summary 201 CRITICAL SKILL 4.9 Call PL/SQL Programs 201 5 The Database Administrator 205 CRITICAL SKILL 5.1 Learn What a DBA Does 206 CRITICAL SKILL 5.2 Perform Day-to-Day Operations 208 Architecture and Design 208 Capacity Planning 208 Backup and Recovery 208 Security 209 Performance and Tuning 209 Managing Database Objects 209 Storage Management 210 Change Management 210 Schedule Jobs 210 Network Management 210 High Availability 211 Troubleshooting 211 CRITICAL SKILL 5.3 Understand the Oracle Database 12c Architecture 211 Schemas 211 Segments, Extents, and Blocks 211 Databases 213 Pluggable Logical Schema Structures 213 Storage Structures 216 CRITICAL SKILL 5.4 Operate Modes for an Oracle Database 12c 217 Modes of Operation 217 Container Database STARTUP 218 Other Ways to Open the Database 218 Forcing a Startup 219 Database and Instance Shutdown 219
Xvi Oracle Database 12c: Install, Configure & Maintain Like a Professional CRITICAL SKILL 5.5 Get Started with Oracle Enterprise Manager 221 Instance Configuration 225 User Sessions 99c ZZJ Resource Consumer Groups 226 Other Tools 228 CRITICAL SKILL 5.6 Understand Database Connections 230 Oracle Net Services 230 Command-Line Utilities 231 Connections 233 Maintain Connections 233 Define a Location 234 A Connect Descriptor 235 Define a Connect Descriptor 236 CRITICAL SKILL 5.7 Manage Database Objects 236 Control Files 236 Redo Logs 237 Undo Management 237 Schema Objects 237 CRITICAL SKILL 5.8 Manage Space 240 Archive Logs 240 Tablespaces and Data Files 240 CRITICAL SKILL 5.9 Manage Users 242 Create a User 243 Edit Users 245 CRITICAL SKILL 5.10 Manage Privileges for Database Users 245 Grant Authority 245 Types of Grants 246 Take Away Authority 246 Roles 246 Oracle-Defined Roles 247 Create and Grant a Role 247 Profiles 247 Tie It All Together 249 Project 5-1 Create Essential Objects 249 Step by Step 249 Project Summary 251 6 Backup and Recovery 253 CRITICAL SKILL 6.1 Understand Rman 254 Rman Metadata 255 CRITICAL SKILL 6.2 See Reasons to Use Rman 256 CRITICAL SKILL 6.3 Understand Storage Media 256
Contents XVli CRITICAL SKILL 6.4 Examine Rman Components 258 Backup 258 Restore 259 Recovery 259 CRITICAL SKILL 6.5 Invoke Rman 259 CRITICAL SKILL 6.6 Learn Rman Commands 262 CRITICAL SKILL 6.7 Review Rman Channels 265 CRITICAL SKILL 6.8 Examine Rman Configuration 267 CRITICAL SKILL 6.9 Explore Backup Commands 269 Database 269 Tablespace 269 Datafile 270 Control File 270 Server Parameter File 270 Archived Redo Logs 270 CRITICAL SKILL 6.10 Conduct Incremental Backups 271 CRITICAL SKILL 6.11 List Backups 272 CRITICAL SKILL 6.1 2 See Rman Metadata 273 CRITICAL SKILL 6.1 3 Use Rman Restore 276 CRITICAL SKILL 6.14 Understand Rman Recover 277 CRITICAL SKILL 6.15 Learn About Backup Retention 277 CRITICAL SKILL 6.16 Check Syntax 278 CRITICAL SKILL 6.1 7 Recover a Table 278 CRITICAL SKILL 6.18 Pull It All Together 279 Backup Script 279 Restore and Recovery Script 280 7 High Availability: RAC, ASM, and Data Guard 283 CRITICAL SKILL 7.1 Define High Availability 284 CRITICAL SKILL 7.2 Understand Real Application Clusters 285 CRITICAL SKILL 7.3 Install RAC 287 CRITICAL SKILL 7.4 Test RAC 292 Workload Manager 293 ASM 293 CRITICAL SKILL 7.4 Set Up the ASM Instance 295 Project 7-1 Install ASMLib 301 Step by Step 301 Project Summary 301 CRITICAL SKILL 7.5 Create ASM Disk Groups 302 Project 7-2 Create Disk Croups 302 Step by Step 303 Project Summary 304
XVlii Oracle Database 12c: Install, Configure & Maintain Like a Professional CRITICAL SKILL 7.6 Use ASMCMD and ASMLib 304 CRITICAL SKILL 7.7 Convert an Existing Database to ASM 305 CRITICAL SKILL 7.8 Understand Data Guard 309 CRITICAL SKILL 7.9 Explain Data Guard Protection Modes 309 CRITICAL SKILL 7.10 Create a Physical Standby Server 313 Project 7-3 Create a Physical Standby Server 314 Step by Step 314 Project Summary 316 8 Using and Managing Large Databases CRITICAL SKILL 8.1 Learn to Identify a Very Large Database 320 CRITICAL SKILL 8.2 How and Why to Use Data Partitioning 321 Why Use Data Partitioning Manageability Performance Implement Data Partitioning Ask the Expert Project 8-1 Create a Range-Partitioned Table and a Local-Partitioned Index 344 Project Summary 319 321 323 324 326 340 346 CRITICAL SKILL 8.3 Compress Your Data 347 347 Data Compression Index 349 Key Compression Automatic Data Optimization 349 CRITICAL SKILL 8.4 Use Parallel Processing to Improve Performance... 351 Parallel Processing Database Components 352 Parallel Processing Configuration 352 Invoke Parallel Execution 353 CRITICAL SKILL 8.5 Use Materialized Views 355 Uses for Materialized Views 356 Query Rewrite 358 When to Create Materialized Views 359 Create Materialized Views 359 CRITICAL SKILL 8.6 Use SQL Aggregate and Analysis Functions 360 Aggregation Functions 360 rollup 360 cube 362 Analytic Functions 363 Windowing Functions 370 Other Functions 371 CRITICAL SKILL 8.7 Create SQL Models 372 Project 8-2 Use Analytic SQL Functions and Models 375 Project Summary 377
Contents xix 9 Oracle's Engineered Systems: From the Database Appliance to Exadata 379 CRITICAL SKILL 9.1 Understand Oracle Database Appliance 381 CRITICAL SKILL 9.2 Manage Oracle Database Appliance 381 Initial Configuration 382 CRITICAL SKILL 9.3 Learn about Exadata's Main Components 383 CRITICAL SKILL 9.4 Understand Exadata Storage 385 Exadata Storage Concepts 386 CRITICAL SKILL 9.5 Accelerate Large Queries with Storage Offload 388 Smart Scan in Action 388 Why Smart Scans May Not Happen 390 CRITICAL SKILL 9.6 Understand Storage Indexes 391 Storage Indexes in Action 392 CRITICAL SKILL 9.7 Use the Exadata Flash Cache 392 Trying Out the Flash Cache 393 CRITICAL SKILL 9.8 Save Storage Space with Hybrid Columnar Compression 394 Hybrid Columnar Compression in Action 396 Using DBMS_COMPRESSION to Estimate Compression 397 CRITICAL SKILL 9.9 Enable Database Consolidation with I/O Resource Management 398 Project 9-1 Create an Interdatabase IORM Plan 399 Step by Step 399 Project Summary 400 CRITICAL SKILL 9.10 Perform Common Exadata Management Tasks... 400 User Accounts on Exadata Storage Servers 400 Using DCLI to Retrieve Metrics from the Storage Server 400 Using EXACHK to Validate Exadata Configurations 401 CRITICAL SKILL 9.11 Manage Exadata with Oracle Enterprise Manager 403 Mastery Check Answers 407 Chapter 1: The Database: The Foundations of 12c 408 Chapter 2: Installing Oracle 409 Chapter 3: SQL: Accessing and Retrieving Data 410 Chapter 4: Programming in the Database 413 Chapter 5: The Database Administrator 414 Chapter 6: Backup and Recovery 417 Chapter 7: High Availability: RAC, ASM, and Data Guard 418 Chapter 8: Using and Managing Large Databases 420 Chapter 9: Oracle's Engineered Systems: From the Database Appliance to Exadata 422 Index 427