Oracle TimesTen 6.0: Core Concepts and Administration Volume I Student Guide D21723GC10 Edition 1.0 February 2006 D44801
Author Danny Lau Technical Contributors and Reviewers Susan Cheung Joe Chung Phil Chung Sam Drake Kirk Edson Philip Fees Chi-Kim Hoang Chris Jenkins Jenny Li Mark McAuliffe Manish Pawar Martin Reames Paul Tuck Chih-Ping Wang Adam Whitter Editors Aju Kumar Nita Pavitran Elizabeth Treacy Copyright 2006, Oracle. All rights reserved. Disclaimer This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle. The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free. Restricted Rights Notice If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS The U.S. Government s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract. Trademark Notice Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Graphic Designers Satish Bettegowda Steve Elwood Sanjeev Sharma Publishers Nita Brozowski Sheryl Domingue Sujatha Nagendra Michael Sebastian Jobi Varghese
Contents 1 Introduction and Course Overview Course Objectives 1-2 Intended Audience and Course Prerequisites 1-3 Agenda 1-4 2 TimesTen Product Overview Objectives 2-2 Real-Time Data Management 2-3 Lightweight, Embeddable, Real-Time In-Memory Database 2-4 Complimentary Database Strengths 2-5 Combined Performance 2-7 Oracle TimesTen In-Memory Database 2-8 Replication TimesTen-to-TimesTen Product Option 2-10 Cache Connect to Oracle Product Option 2-11 Developing TimesTen Applications 2-12 MicroLogging TM Protection: Resilience to Application Failures 2-13 Data Publishing: Transaction Log API 2-14 Architecture Comparison 2-15 Finding a Row of Data in a Conventional RDBMS 2-17 Finding a Row of Data in TimesTen 2-18 What s New: Oracle TimesTen In-Memory Database, Release 6.0 2-19 Summary 2-23 3 TimesTen System Architecture Objectives 3-2 TimesTen Processes and Files 3-3 First Data Store Connection 3-5 Processing Updates on a Data Store 3-6 Concurrent Data Store Connections 3-7 Data Store Client/Server Connections 3-8 Summary 3-10 4U Installing TimesTen on UNIX Systems Objectives 4U-2 Supported UNIX Platforms 4U-3 Installation Prerequisites and Requirements 4U-10 TimesTen Installation Script 4U-14 Environment Variables 4U-24 TimesTen Data Manager Demo Programs 4U-26 TimesTen Documentation 4U-28 Summary 4U-30 iii
4M Installing TimesTen on Microsoft Windows Systems Objectives 4M-2 Installation Prerequisites and Requirements 4M-3 TimesTen Installation Program 4M-7 TimesTen Product Selection 4M-9 TimesTen Installation Directory 4M-10 Installation Setup Type 4M-11 TimesTen Demo Data Store Directory 4M-12 Program Folder Name 4M-13 Environment Variables and Data Store Access Control 4M-14 TimesTen Client Environment Variables 4M-15 Cache Connect to Oracle Administrator Access 4M-16 JDK Version 4M-17 Verify Settings 4M-18 TimesTen Server Parameters 4M-19 TimesTen Client Parameters 4M-20 TimesTen Main Daemon Web Server Parameters 4M-21 Complete the Installation Program 4M-22 Environment Variables 4M-24 TimesTen Data Manager Demo Programs 4M-25 TimesTen Documentation 4M-27 Summary 4M-29 5 Defining Data Manager Data Sources Objectives 5-2 Data Sources and Data Stores 5-3 Defining Data Manager DSNs on Microsoft Windows Systems 5-5 Defining Data Manager DSNs on UNIX Systems 5-10 UNIX Systems Data Manager DSN Example 5-12 TimesTen Data Source Attributes 5-14 Data Store Creation Attributes 5-16 Data Store Connection Attributes 5-18 Data Store Sizing Attributes 5-24 Logging and Durability Attributes 5-28 Locking and Concurrency Attributes 5-36 Statement Execution Attributes 5-40 Cache Connect to Oracle Attributes 5-42 ttisql Utility 5-44 Connection Strings 5-51 Data Source Attribute Settings Precedence Rules 5-52 Connecting to a Data Source 5-53 Data Store System Considerations 5-57 ttstatus Utility: Data Store Connections 5-59 Disconnecting from a Data Source 5-66 Summary 5-67 iv
6 Creating Data Store Elements Objectives 6-2 Data Store Elements 6-3 Tables 6-4 Columns 6-5 Basic Names 6-6 Basic Names Examples 6-7 Data Types 6-8 SQL Table DDL Statements 6-13 Default Column Value 6-20 Default Column Value Examples 6-21 Primary Key and Unique Column Constraint 6-22 Primary Key and Unique Column Constraint Examples 6-24 Foreign Key 6-26 Foreign Key Example 6-28 Indexes 6-29 Hash Index 6-30 Hash Index Example 6-31 T-tree Index 6-32 SQL Index DDL Statements 6-33 Altering a Table 6-36 Altering a Table Examples 6-38 Data Store Element Owners 6-39 Data Store Element Owners Examples 6-40 User IDs and Passwords 6-41 TimesTen System Tables 6-42 ttsize Utility: Estimating Table Size 6-45 ttsize Utility: Estimating Table Size Example 6-47 Determining Data Store Sizes 6-48 SYS.MONITOR System Table: Data Store Connections and Sizes 6-50 Summary 6-53 7 Accessing Data Store Elements Objectives 7-2 Constants 7-3 SQL DML Statements 7-7 SQL DML Statements Examples 7-12 TRUNCATE TABLE Statement 7-14 Search Conditions: BETWEEN, Comparison, and IN 7-15 BETWEEN, Comparison, and IN Predicates Examples 7-17 Search Conditions: IS NULL, LIKE, and Quantified 7-18 Functions and Operators: Aggregates, Bit Manipulation, and MOD 7-20 Functions and Operators: NVL, LOWER, UPPER, CONCAT, and RTRIM 7-23 NVL, LOWER, UPPER, CONCAT, and RTRIM Functions Examples 7-25 Functions and Operators: SYSDATE, GETDATE, TO_CHAR, and TO_DATE 7-26 v
Functions and Operators: INSTR, LENGTH, and SUBSTR 7-30 INSTR, LENGTH, and SUBSTR Functions Examples 7-32 CAST Operator and CASE Expression 7-33 CAST Operator and CASE Expression Examples 7-35 Datetime and Interval Arithmetic Operations 7-36 EXTRACT, NUMTOYMINTERVAL, and NUMTODSINTERVAL Functions 7-37 Datetime and Interval Arithmetic Operations Examples 7-39 GROUP BY Clause 7-40 GROUP BY Clause Examples 7-41 Table Joins 7-42 Table Join Query Examples 7-44 Subqueries 7-46 Subqueries Examples 7-48 Row ID 7-49 Sequences 7-51 Accessing Sequences 7-53 Views 7-55 Views Examples 7-58 Preparing and Executing Statements 7-60 Parameterized Statements 7-65 Parameterized Statements Example 7-66 TimesTen Built-In Procedures 7-67 Summary 7-69 8 Managing Data Stores Objectives 8-2 Data Store Management Utilities: ttbulkcp Utility 8-3 ttbulkcp Utility Examples 8-10 Data Store Management Utilities: ttdestroy Utility 8-11 ttbackup Utility Examples 8-16 Data Store Management Utilities: ttrestore Utility 8-17 Data Store Management Utilities: ttmigrate Utility 8-19 ttmigrate Utility Examples 8-23 Data Store Management Utilities: ttschema Utility 8-24 ttschema Utility 8-25 Data Store Checkpoints 8-26 Types of Checkpoint Operations 8-28 Manually or Automatically Initiating a Checkpoint 8-30 Growing and Shrinking a Data Store 8-35 SYS.MONITOR System Table: Checkpoints and Compacts 8-38 ttadmin Utility: Configuring Data Store RAM Policy 8-39 ttstatus Utility: RAM Policy Status 8-41 TimesTen Daemon Processes or Data Manager Service 8-45 Starting and Stopping the Main Daemon Processes or Data Manager Service 8-48 Starting and Stopping the Main Daemon Processes or Data Manager Service: Examples 8-50 vi
ttstatus Utility: Main Daemon Status 8-51 ttmodinstall Utility 8-52 Access Control 8-53 Defining Users 8-55 Defining Privileges 8-59 Summary 8-61 9 Transactions and Concurrency Control Objectives 9-2 Concurrency Options and Transaction Semantics 9-3 Autocommit 9-4 Starting and Completing Transactions 9-6 Transaction Logging 9-8 Durable Commits 9-13 Locking and Timeout Interval 9-15 Locking and Granularity Level 9-17 Transaction Isolation Levels 9-19 Serializable Isolation 9-20 Read Committed Isolation 9-21 ttxactadmin Utility 9-22 ttxactadmin Utility Example 9-25 Concurrent Data Store Connections and Multiprocessor Systems Considerations 9-28 SELECT.. FOR UPDATE Statement 9-30 SYS.MONITOR System Table: Transactions, Logging, and Locks 9-31 Summary 9-33 10 Performance Tuning and Query Optimization Objectives 10-2 Use of Hash and T-tree Indexes 10-3 Indexing Considerations 10-5 SQL DDL Performance Considerations 10-6 Performance Tuning of Materialized Views 10-8 Prefetching Rows from a Result Set 10-10 Query Optimizer Column and Table Statistics 10-11 Computing Statistics 10-12 TimesTen Query Optimizer 10-19 Generating an Execution Plan 10-20 Viewing an Execution Plan 10-21 Query Optimizer Hints 10-26 SYS.MONITOR System Table: Preparing Statements and Temporary Indexes 10-37 Timing Statement Execution 10-39 Summary 10-41 vii
11 Configuring TimesTen Client/Server Objectives 11-2 Two Ways to Connect to a Data Store 11-3 TimesTen Client/Server Overview 11-4 Client/Server Example 11-5 Client/Server Setup and Configuration 11-6 Server DSNs 11-7 Defining Server DSNs on Microsoft Windows Systems 11-8 Defining Server DSNs on UNIX Systems 11-9 Logical Server Names 11-10 Defining Logical Server Names on Microsoft Windows Systems 11-11 Defining Logical Server Names on UNIX Systems 11-12 Client DSNs 11-13 Defining Client DSNs on Microsoft Windows Systems 11-14 Defining Client DSNs on UNIX Systems 11-16 Configuring Pre-TimesTen 6.0 Clients Access to 6.0 Server Data Stores 11-18 Alternate Communication Modes for Local Client/Server Access 11-19 Accessing a Data Store in Client/Server Mode 11-21 Testing Client Connections from Microsoft Windows Systems 11-22 TimesTen Client Demo Programs 11-24 Starting and Stopping the TimesTen Server Process 11-26 ttstatus Utility: Server Status and Client Connections 11-28 Troubleshooting TimesTen Client/Server 11-29 Summary 11-32 12 Troubleshooting TimesTen Objectives 12-2 The Daemon Log 12-3 Configuring the Daemon Log on UNIX Systems 12-5 Viewing the Daemon Log Messages on Microsoft Windows Systems 12-7 ttdaemonlog Utility 12-8 Interpreting Daemon Log Messages 12-11 ttcapture Utility 12-23 SNMP Traps 12-25 Problems Connecting to a Data Store 12-27 Problems Accessing Tables 12-30 Performance Problems 12-32 Problems with Hanging Applications 12-35 Problems with Checkpoint and Transaction Log Files 12-37 TimesTen Internal Tracing Facilities 12-39 ODBC Tracing on Microsoft Windows Systems 12-43 ttcheck Utility 12-44 ttxactlog Utility 12-46 Summary 12-48 Appendix A: Practices Appendix B: Solutions viii