Expert One-on-One Oracle [1 ed.] 9781590592434, 1590592433

Thomas Kyte has a simple philosophy: You can treat Oracle as a black box and shove data inside of it, or you can learn h

354 115 9MB

English Pages 1544 Year 2003

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Introduction......Page 17
What this Book is About......Page 18
Who Should Use this Book?......Page 19
How This Book is Structured......Page 20
Understanding the Database......Page 21
Database Structures and Utilities......Page 22
Advanced SQL Features......Page 23
Extensibility......Page 24
Security......Page 25
Conventions......Page 26
Source Code and Updates......Page 27
The SQL*PLUS Environment......Page 28
Setting up AUTOTRACE in SQL*PLUS......Page 30
Interpreting the Execution Plan......Page 31
Coding Conventions......Page 32
Other Issues......Page 33
Overview......Page 35
My Approach......Page 36
The Black Box Approach......Page 37
Understanding Oracle Architecture......Page 41
Do not run Long Transactions Under MTS......Page 42
Use Bind Variables......Page 45
Understanding Concurrency Control......Page 48
Implementing Locking......Page 49
Multi-Versioning......Page 52
Database Independence?......Page 57
The Impact of Standards......Page 61
Features and Functions......Page 65
Solving Problems Simply......Page 67
Openness......Page 69
How Do I Make it Run Faster?......Page 71
The DBA-Developer Relationship......Page 73
Summary......Page 74
The Server......Page 76
Parameter Files......Page 84
Data Files......Page 87
Control Files......Page 91
Redo Log Files......Page 92
Online Redo Log......Page 93
Archived Redo Log......Page 95
Files Wrap-Up......Page 96
PGA and UGA......Page 97
SGA......Page 103
Redo Buffer......Page 106
Block Buffer Cache......Page 107
Shared Pool......Page 110
Large Pool......Page 112
Java Pool......Page 114
The Processes......Page 115
Server Processes......Page 116
Dedicated Server versus Shared Server......Page 119
A Recommendation......Page 121
Focused Background Processes......Page 122
PMON - The Process Monitor......Page 123
SMON - The System Monitor......Page 124
RECO - Distributed Database Recovery......Page 125
DBWn - Database Block Writer......Page 126
LGWR - Log Writer......Page 127
LMD - Lock Manager Daemon......Page 128
SNPn - Snapshot Processes (Job Queues)......Page 129
Slave Processes......Page 130
Parallel Query Slaves......Page 131
Summary......Page 132
What are Locks?......Page 133
Lost Updates......Page 136
Pessimistic Locking......Page 137
Optimistic Locking......Page 139
Blocked Inserts......Page 140
Deadlocks......Page 141
Lock Escalation......Page 146
DML Locks......Page 147
TX - (Transaction) Locks......Page 148
TM - (DML Enqueue) Locks......Page 154
DDL Locks......Page 155
Latches and Internal Locks (Enqueues)......Page 159
Manual Locking......Page 160
What is Concurrency Control?......Page 161
Transaction Isolation Levels......Page 162
READ UNCOMMITTED......Page 163
READ COMMITTED......Page 165
Getting a Consistent Answer......Page 167
Lost Update Prevention......Page 169
SERIALIZABLE......Page 170
Read-Only Transactions......Page 172
Summary......Page 173
Transaction Control Statements......Page 175
Integrity Constraints and Transactions......Page 182
Bad Transaction Habits......Page 184
Distributed Transactions......Page 191
Redo and Rollback......Page 194
Summary......Page 198
Redo......Page 200
What Does a COMMIT Do?......Page 201
What Does a ROLLBACK Do?......Page 208
How Much Redo Am I Generating?......Page 209
Can I Turn Off Redo Log Generation?......Page 221
Cannot Allocate a New Log?......Page 224
Block Cleanout......Page 226
Log Contention......Page 230
Temporary Tables and Redo/Rollback......Page 232
Analyzing Redo......Page 235
SET TRANSACTION......Page 236
'ORA-01555: snapshot too old'......Page 237
Rollback Segments Are in Fact Too Small......Page 239
You Fetch Across COMMITs......Page 243
Delayed Block Cleanout......Page 246
Summary......Page 250
Types of Tables......Page 252
High Water Mark......Page 254
FREELISTS......Page 255
Row Migration......Page 258
Setting PCTFREE and PCTUSED values......Page 260
MINEXTENTS and MAXEXTENTS......Page 265
Heap Organized Table......Page 266
Index Organized Tables......Page 271
Index Clustered Tables......Page 286
Hash Cluster Tables......Page 295
Nested Tables......Page 306
Nested Tables Syntax......Page 307
Nested Table Storage......Page 317
Nested Tables Wrap-up......Page 320
Temporary Tables......Page 321
Temporary Table Wrap-up......Page 329
Object Tables......Page 330
Summary......Page 339
Overview......Page 341
An Overview of Oracle Indexes......Page 342
B*Tree Indexes......Page 343
Reverse Key Indexes......Page 348
Descending Indexes......Page 350
When should you use a B*Tree Index?......Page 351
B*Trees Wrap-up......Page 360
Bitmap Indexes......Page 361
When Should you use a Bitmap Index?......Page 362
Function-Based Indexes......Page 364
Function-Based Index Example......Page 365
Caveat......Page 375
Application Domain Indexes......Page 376
Indexes and Nulls......Page 378
Indexes on Foreign Keys......Page 382
Case 1......Page 383
Case 4......Page 384
Case 5......Page 386
Case 6......Page 388
Are my Indexes Being Used?......Page 389
Myth: Space is Never Reused in an Index......Page 390
Myth: Most Discriminating Elements Should be First......Page 394
Summary......Page 398
A Quick Example......Page 400
Detecting Corruption......Page 402
Rebuilding Instances......Page 403
The Options......Page 404
EXP Parameters......Page 405
IMP Parameters......Page 407
Large Exports......Page 409
Use the FILESIZE Parameter......Page 410
Export to an OS Pipe......Page 412
Subsetting Data......Page 414
Transporting Data......Page 415
Getting the DDL......Page 421
Getting around the limitations with scripts......Page 425
IMP/EXP is not a Reorganization Tool (Any More)......Page 429
Importing into Different Structures......Page 430
Direct Path Exports......Page 435
Cloning......Page 436
Using IMP/EXP Across Versions......Page 445
Where did my Indexes go?......Page 446
Named versus Default-Named Constraints......Page 449
National Language Support (NLS) Issues......Page 453
Tables Spanning Multiple Tablespaces......Page 455
Summary......Page 461
An Introduction to SQL*LOADER......Page 462
Load Delimited Data......Page 469
Load Fixed Format Data......Page 473
Load Dates......Page 476
Load Data Using Sequences and Other Functions......Page 477
Update Existing Rows and Insert New Rows......Page 483
Load Report-Style Input Data......Page 486
Load a File into a LONG RAW or LONG Field......Page 489
Load Data with Embedded Newlines......Page 490
Use a Character Other than a Newline......Page 491
Use the FIX Attribute......Page 492
Use the VAR Attribute......Page 499
Use the STR Attribute......Page 500
Embedded Newlines Wrap-Up......Page 501
Unload Data......Page 502
Load a LOB via PL/SQL......Page 514
Load LOB Data that is Inline......Page 518
Load LOB Data that is Out of Line......Page 520
Load LOB Data into Object Columns......Page 523
Load VARRAYS/Nested Tables with SQLLDR......Page 526
Call SQLLDR from a Stored Procedure......Page 529
SQLLDR Defaults to CHAR(255)......Page 535
Summary......Page 536
Identifying the Problem......Page 537
My Approach......Page 539
Design for Performance......Page 540
Try many Approaches......Page 542
Benchmark......Page 543
Bind Variables and Parsing (Again)......Page 545
Am I Using Bind Variables?......Page 562
SQL_TRACE, TIMED_STATISTICS, and TKPROF......Page 565
Setting Up Tracing......Page 566
Using and Interpreting TKPROF Output......Page 569
Using and Interpreting Raw Trace Files......Page 580
SQL_TRACE, TIMED_STATISTICS, and TKPROF Wrap-Up......Page 593
Instrumentation......Page 594
Setting up StatsPack......Page 597
StatsPack Wrap-Up......Page 618
V$EVENT_NAME......Page 619
V$MYSTAT......Page 620
V$OPEN_CURSOR......Page 622
V$SESSION......Page 623
V$SESSION_EVENT......Page 626
V$SQL, V$SQLAREA......Page 627
Summary......Page 628
An Overview of the Feature......Page 630
A Method to Implement Tuning......Page 634
A Development Tool......Page 640
To See what SQL is Executed by an Application......Page 642
The _OUTLINES Views......Page 643
The _OUTLINE_HINTS Views......Page 645
Privileges Needed for Stored Outlines......Page 646
Using DDL......Page 647
Using ALTER SESSION......Page 648
The OUTLN User......Page 649
Moving Outlines from Database to Database......Page 650
Getting Just the Right Outline......Page 651
ALTER OUTLINE......Page 654
The OUTLN_PKG Package......Page 657
OUTLN_PKG.DROP_UNUSED......Page 658
OUTLN_PKG.UPDATE_BY_CAT......Page 659
Outline Names and Case......Page 661
DROP USER does not Drop Outlines......Page 663
'CURSOR_SHARING = FORCE' and Outlines......Page 664
Outlines Use Simple Text Matching......Page 665
OR-Expansion......Page 666
Performance......Page 667
The Namespace of Outlines is Global......Page 672
ORA-18001 "no options specified for ALTER OUTLINE"......Page 673
ORA-18005-18007......Page 674
Summary......Page 675
An Example......Page 676
The Syntax......Page 681
The Function Clause......Page 682
The Partition Clause......Page 683
The Order By Clause......Page 684
The Windowing Clause......Page 687
Range Windows......Page 689
Row Windows......Page 692
Specifying Windows......Page 695
The Functions......Page 698
The TOP-N Query......Page 702
Pivot Query......Page 714
Accessing Rows Around Your Current Row......Page 723
PL/SQL and Analytic functions......Page 728
Analytic Functions in the Where Clause......Page 730
NULLS and Sorting......Page 731
Performance......Page 733
Summary......Page 734
A Brief History......Page 735
An Example......Page 737
How Materialized Views Work......Page 745
Setting Up......Page 746
Internal Mechanics......Page 747
General Query Rewrite Methods......Page 748
Grouping Compatibility......Page 749
Constraints......Page 750
Dimensions......Page 756
Estimating Size......Page 767
Dimension Validation......Page 769
Recommending Materialized Views......Page 772
Query Rewrite Integrity......Page 774
Summary......Page 775
Increased Availability......Page 777
Reduced Administrative Burden......Page 780
Enhanced DML and Query Performance......Page 781
How Partitioning Works......Page 783
Table Partitioning Schemes......Page 784
Partitioning Indexes......Page 789
Local Indexes......Page 790
Local Indexes and Uniqueness......Page 797
Global Indexes......Page 800
Data Warehousing and Global Indexes......Page 803
OLTP and Global Indexes......Page 807
Summary......Page 813
An Example......Page 814
Auditing that Can Not be Rolled Back......Page 817
A Method to Avoid a Mutating Table......Page 821
Performing DDL in Triggers......Page 822
Writing to the Database......Page 828
Really Strict Auditing......Page 829
When the Environment Only Allows SELECTs......Page 834
How They Work......Page 839
Transactional Control......Page 840
Packaged Variables......Page 842
Session Settings/Parameters......Page 843
Database Changes......Page 844
Locks......Page 848
Ending an Autonomous Transaction......Page 849
Savepoints......Page 850
The Entire Transaction Rolls Back......Page 853
Transaction-Level Temporary Tables......Page 855
Mutating Tables......Page 857
ORA-14450 "attempt to access a transactional temp table already in use"......Page 860
Summary......Page 861
Dynamic SQL versus Static SQL......Page 862
Why Use Dynamic SQL?......Page 865
DBMS_SQL......Page 866
Native Dynamic SQL......Page 874
Bind Variables......Page 880
Number of Outputs Unknown at Compile-Time......Page 886
Executing the Same Statement Dynamically Many Times......Page 894
Caveats......Page 906
It Breaks the Dependency Chain......Page 907
Summary......Page 908
A Brief History......Page 910
Uses of interMedia Text......Page 911
Searching for Text......Page 912
Managing a Variety of Documents......Page 914
Indexing Text from Many Data Sources......Page 915
It's an Oracle Database, After All......Page 919
Generating Themes......Page 920
Searching XML Applications......Page 922
How interMedia Text Works......Page 923
interMedia Text Indexing......Page 927
About ABOUT......Page 931
Section Searching......Page 932
Index Synchronization......Page 940
Indexing Information Outside the Database......Page 941
Document Services......Page 942
The Catalog Index......Page 943
Errors You May Encounter......Page 945
External Procedure Errors......Page 946
Summary......Page 947
When Are They Used?......Page 949
How Are They Implemented?......Page 951
Configuring Your Server......Page 953
Verify the Database Environment......Page 956
Verify the Listener......Page 958
Compile extproc.c Code......Page 959
Set Up the SCOTT/TIGER Account......Page 960
Create the demolib Library......Page 961
Installing and Running......Page 962
Our First External Procedure......Page 963
The Wrapper......Page 964
The C Code......Page 976
Building the extproc......Page 1004
Installing and Running......Page 1008
LOB to File External Procedure (LOB_IO)......Page 1009
The LOB_IO Call Specification......Page 1010
The LOB_IO Pro*C Code......Page 1012
Building the extproc......Page 1017
Installing and Using LOB_IO......Page 1019
ORA-28575 "unable to open RPC connection to external procedure agent"......Page 1025
ORA-28576 "lost RPC connection to external procedure agent"......Page 1026
ORA-28578 "protocol error during callback from an external procedure"......Page 1027
ORA-28580 "recursive external procedures are not supported"......Page 1028
ORA-06520 "PL/SQL: Error loading external library"......Page 1029
ORA-06521 "PL/SQL: Error mapping function"......Page 1030
ORA-06523 "Maximum number of arguments exceeded"......Page 1031
ORA-06526 "Unable to load PL/SQL library"......Page 1032
Summary......Page 1033
Why Use Java Stored Procedures?......Page 1035
How They Work......Page 1037
Passing Data......Page 1042
Useful Examples......Page 1053
Getting a Directory Listing......Page 1054
Running an OS Command......Page 1057
Getting Time Down to the Milliseconds......Page 1060
Permissions Errors......Page 1061
ORA-29531 no method X in class Y......Page 1062
Summary......Page 1063
Overview......Page 1064
How Object Relational Features Work......Page 1065
Adding Data Types to your System......Page 1066
Adding Data Types Wrap-Up......Page 1082
Creating a New PL/SQL Data Type......Page 1083
Unique Uses for Collections......Page 1095
SELECT * from PLSQL_FUNCTION......Page 1096
Bulk Fetching into RECORD Types......Page 1100
Using Types to Extend PL/SQL Wrap-Up......Page 1101
The Types......Page 1102
The O-R View......Page 1103
Summary......Page 1118
An Example......Page 1120
Ease of Maintenance......Page 1121
Performed in the Server......Page 1122
Easier Application Development......Page 1123
Hosting an Application as an ASP......Page 1124
How it Works......Page 1125
Example 1: Implementing a Security Policy......Page 1127
Example 2: Using Application Contexts......Page 1132
Referential Integrity......Page 1154
The Covert Channel......Page 1155
Deleting Rows......Page 1157
Updating Rows......Page 1158
Cursor Caching......Page 1160
Export/Import......Page 1168
Export Issues......Page 1169
Import Issues......Page 1171
Debugging......Page 1172
ORA-28110: policy function or package has error.......Page 1173
ORA-28112: failed to execute policy function.......Page 1175
ORA-28113: policy predicate has error.......Page 1176
Summary......Page 1178
Why Use n-Tier Authentication?......Page 1180
The Mechanics of n-Tier Authentication......Page 1183
Granting the Privilege......Page 1194
Auditing Proxy Accounts......Page 1195
Caveats......Page 1196
Summary......Page 1198
An Example......Page 1199
Developing Generic Utilities......Page 1203
Data Dictionary Applications......Page 1208
Generic Object Types......Page 1211
Implementing your own Access Control......Page 1212
Performance and Scalability......Page 1215
Security......Page 1216
Definer Rights......Page 1217
Definer Rights and Roles......Page 1221
Invoker Rights......Page 1222
Resolving References and Conveying Privileges......Page 1224
Compiling an Invoker Rights Procedure......Page 1230
Using Template Objects......Page 1231
Invoker Rights and Shared Pool Utilization......Page 1235
Performance......Page 1239
Code must be more Robust in Handling Errors......Page 1242
Side Effects of Using SELECT *......Page 1244
Beware of the 'Hidden' Columns......Page 1245
Java and Invoker Rights......Page 1247
Summary......Page 1254
Overview......Page 1256
About The Supplied Packages......Page 1257
Why You Might Use Them......Page 1260
DBMS_ALERT......Page 1261
Concurrent Signals by More than One Session......Page 1264
Repeated Calls to Signal by a Session......Page 1266
Many Calls to Signal by Many Sessions before a Wait Routine is Called......Page 1267
DBMS_PIPE......Page 1268
Pipe Servers versus External Routines......Page 1271
Summary......Page 1273
Overview......Page 1274
Using the Client Info......Page 1275
Using V$SESSION_LONGOPS......Page 1278
Summary......Page 1283
LONGNAME and SHORTNAME......Page 1284
Setting Compiler Options......Page 1285
SET_OUTPUT......Page 1289
loadjava and dropjava......Page 1290
Permission Procedures......Page 1291
Summary......Page 1293
Overview......Page 1294
Running a Job Once......Page 1298
Ongoing Jobs......Page 1302
Custom Scheduling......Page 1305
Monitoring the Jobs and Finding the Errors......Page 1307
Summary......Page 1310
Overview......Page 1311
substr......Page 1312
SELECT FOR UPDATE and Java......Page 1313
From BLOB to VARCHAR2 and Back Again......Page 1316
Converting From LONG/LONG RAW to a LOB......Page 1321
Performing a Mass One-Time Conversion Illustration......Page 1323
Performing an 'on the fly' Conversion......Page 1327
How to Write a BLOB/CLOB to Disk......Page 1330
Displaying a LOB on the Web Using PL/SQL......Page 1331
Summary......Page 1333
Overview......Page 1334
Summary......Page 1338
Overview......Page 1339
Step 1: Creating the Data Dictionary......Page 1341
Step 2: Using Log Miner......Page 1345
Options and Usage......Page 1352
Using Log Miner to Find Out When.........Page 1355
PGA Usage......Page 1357
Oracle Object Types......Page 1359
Chained or Migrated Rows......Page 1363
Other limits......Page 1366
V$LOGMNR_CONTENTS......Page 1367
Summary......Page 1370
Overview......Page 1372
The Wrapper......Page 1374
Caveats......Page 1392
The Client Application Manages and Stores Keys......Page 1394
Store the Keys in the Same Database......Page 1395
Store the Keys in the File System with the Database......Page 1396
Summary......Page 1397
Overview......Page 1398
How DBMS_OUTPUT Works......Page 1399
DBMS_OUTPUT and Other Environments......Page 1404
Using A Small Wrapper Function or Another Package......Page 1409
Creating DBMS_OUTPUT Functionality......Page 1411
Summary......Page 1418
Overview......Page 1419
Caveats......Page 1431
Summary......Page 1432
COMPILE_SCHEMA......Page 1433
ANALYZE_SCHEMA......Page 1438
ANALYZE_SCHEMA does not Analyze Everything......Page 1440
FORMAT_ERROR_STACK......Page 1442
FORMAT_CALL_STACK......Page 1444
GET_TIME......Page 1448
GET_PARAMETER_VALUE......Page 1449
NAME_RESOLVE......Page 1450
NAME_TOKENIZE......Page 1453
COMMA_TO_TABLE, TABLE_TO_COMMA......Page 1457
DB_VERSION and PORT_STRING......Page 1459
GET_HASH_VALUE......Page 1460
Summary......Page 1466
The UTL_FILE_DIR init.ora parameter......Page 1467
Accessing Mapped Windows Drives......Page 1469
Handling Exceptions......Page 1471
Dumping a Web Page to Disk......Page 1472
1023 Byte Limit......Page 1473
Reading A Directory......Page 1474
Summary......Page 1476
UTL_HTTP Functionality......Page 1477
Adding SSL to UTL_HTTP......Page 1480
Really Using UTL_HTTP......Page 1487
A Better UTL_HTTP......Page 1490
Summary......Page 1501
Overview......Page 1503
UTL_SMTP - a larger example......Page 1506
Loading and using the JavaMail API......Page 1512
Summary......Page 1521
Overview......Page 1522
The SocketType......Page 1523
Summary......Page 1537
How To Enroll For Support......Page 1539
Why This System Offers The Best Support......Page 1540
Add an Erratum......Page 1541
What We Can't Answer......Page 1542
How to Tell Us Exactly What You Think......Page 1543

Expert One-on-One Oracle [1 ed.]
 9781590592434, 1590592433

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Recommend Papers