1. Trang chủ
  2. » Công Nghệ Thông Tin

expert one-on-one oracle

1,5K 5,7K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.544
Dung lượng 8,29 MB

Nội dung

 WWW.EBOOKWORLD.CO.NR Expert one-on-one Oracle 2   This page intentionally left blank Expert one-on-one Oracle 3 Content Introduction 18 WhatthisBookisAbout 18 WhoShouldUsethisBook? 19 HowThisBookisStructured 20 UnderstandingtheDatabase 21 DatabaseStructuresandUtilities 22 Performance 23 AdvancedSQLFeatures 23 Extensibility 24 Security 25 Appendices 26 Conventions 26 SourceCodeandUpdates 27 SettingUp 28 Overview 28 TheSQL*PLUSEnvironment 28 SettingupAUTOTRACEinSQL*PLUS 30 CCompilers 32 CodingConventions 32 OtherIssues 33 Chapter1:DevelopingSuccessfulOracleApplications 35 Overview 35 MyApproach 36 TheBlackBoxApproach 37 How(andhownot)toDevelopDatabaseApplications 41 UnderstandingOracleArchitecture 41 UnderstandingConcurrencyControl 48 DatabaseIndependence? 57 HowDoIMakeitRunFaster? 71 TheDBA‐DeveloperRelationship 73 Summary 74 Chapter2:Architecture 76 Overview 76 TheServer 76 TheFiles 84 ParameterFiles 84 DataFiles 87 TempFiles 91 ControlFiles 91 RedoLogFiles 92 Expert one-on-one Oracle 4 FilesWrap‐Up 96 TheMemoryStructures 97 PGAandUGA 97 SGA 103 MemoryStructuresWrap‐Up 115 TheProcesses 115 ServerProcesses 116 BackgroundProcesses 122 SlaveProcesses 130 Summary 132 Chapter3:LockingandConcurrency 133 Overview 133 WhatareLocks? 133 LockingIssues 136 LostUpdates 136 Blocking 140 Deadlocks 141 LockEscalation 146 TypesofLock 147 DMLLocks 147 DDLLocks 155 LatchesandInternalLocks(Enqueues) 159 ManualLockingandUser‐DefinedLocks 160 WhatisConcurrencyControl? 161 TransactionIsolationLevels 162 READUNCOMMITTED 163 READCOMMITTED 165 REPEATABLEREAD 167 SERIALIZABLE 170 Read‐OnlyTransactions 172 Summary 173 Chapter4:Transactions 175 Overview 175 TransactionControlStatements 175 IntegrityConstraintsandTransactions 182 BadTransactionHabits 184 DistributedTransactions 191 RedoandRollback 194 Summary 198 Chapter5:RedoandRollback 200 Overview 200 Redo 200 WhatDoesaCOMMITDo? 201 Expert one-on-one Oracle 5 WhatDoesaROLLBACKDo? 208 HowMuchRedoAmIGenerating? 209 CanITurnOffRedoLogGeneration? 221 CannotAllocateaNewLog? 224 BlockCleanout 226 LogContention 230 TemporaryTablesandRedo/Rollback 232 AnalyzingRedo 235 Rollback 236 WhatGeneratestheMost/LeastUndo? 236 SETTRANSACTION 236 ʹORA‐01555:snapshottoooldʹ 237 Summary 250 Chapter6:DatabaseTables 252 Overview 252 TypesofTables 252 Terminology 254 HighWaterMark 254 FREELISTS 255 PCTFREEandPCTUSED 258 INITIAL,NEXT,andPCTINCREASE 265 MINEXTENTSandMAXEXTENTS 265 LOGGINGandNOLOGGING 266 INITRANSandMAXTRANS 266 HeapOrganizedTable 266 IndexOrganizedTables 271 IndexOrganizedTablesWrap‐up 286 IndexClusteredTables 286 IndexClusteredTablesWrap‐up 295 HashClusterTables 295 HashClustersWrap‐up 306 NestedTables 306 NestedTablesSyntax 307 NestedTableStorage 317 NestedTablesWrap‐up 320 TemporaryTables 321 TemporaryTableWrap‐up 329 ObjectTables 330 ObjectTableWrap‐up 339 Summary 339 Chapter7:Indexes 341 Overview 341 AnOverviewofOracleIndexes 342 Expert one-on-one Oracle 6 B*TreeIndexes 343 ReverseKeyIndexes 348 DescendingIndexes 350 WhenshouldyouuseaB*TreeIndex? 351 B*TreesWrap‐up 360 BitmapIndexes 361 WhenShouldyouuseaBitmapIndex? 362 BitmapIndexesWrap‐up 364 Function‐BasedIndexes 364 ImportantImplementationDetails 365 Function‐BasedIndexExample 365 Caveat 375 Function‐BasedIndexWrap‐up 376 ApplicationDomainIndexes 376 ApplicationDomainIndexesWrap‐up 378 FrequentlyAskedQuestionsAboutIndexes 378 DoIndexesWorkOnViews? 378 IndexesandNulls 378 IndexesonForeignKeys 382 WhyisnʹtmyIndexGettingUsed? 383 AremyIndexesBeingUsed? 389 Myth:SpaceisNeverReusedinanIndex 390 Myth:MostDiscriminatingElementsShouldbeFirst 394 Summary 398 Chapter8:ImportandExport 400 Overview 400 AQuickExample 400 WhyYouMightUseIMPandEXP 402 DetectingCorruption 402 ExtractingDDL 403 CloningSchemas 403 TransportingTablespaces 403 RebuildingInstances 403 CopyingDatabetweenPlatforms 404 HowTheyWork 404 TheOptions 404 LargeExports 409 SubsettingData 414 TransportingData 415 GettingtheDDL 421 BackupandRecovery 429 IMP/EXPisnotaReorganizationTool(AnyMore) 429 ImportingintoDifferentStructures 430 Expert one-on-one Oracle 7 DirectPathExports 435 CaveatsandErrors 436 Cloning 436 UsingIMP/EXPAcrossVersions 445 WheredidmyIndexesgo? 446 NamedversusDefault‐NamedConstraints 449 NationalLanguageSupport(NLS)Issues 453 TablesSpanningMultipleTablespaces 455 Summary 461 Chapter9:DataLoading 462 Overview 462 AnIntroductiontoSQL*LOADER 462 Howto 469 LoadDelimitedData 469 LoadFixedFormatData 473 LoadDates 476 LoadDataUsingSequencesandOtherFunctions 477 UpdateExistingRowsandInsertNewRows 483 LoadReport‐StyleInputData 486 LoadaFileintoaLONGRAWorLONGField 489 LoadDatawithEmbeddedNewlines 490 UnloadData 502 LoadLOBs 514 LoadVARRAYS/NestedTableswithSQLLDR 526 CallSQLLDRfromaStoredProcedure 529 Caveats 535 YouCannotPickaRollbackSegmenttoUse 535 TRUNCATEAppearstoWorkDifferently 535 SQLLDRDefaultstoCHAR(255) 535 CommandLineOverridesControlFile 536 Summary 536 Chapter10:TuningStrategiesandTools 537 Overview 537 IdentifyingtheProblem 537 MyApproach 539 TuningisaConstantthing 540 BindVariablesandParsing(Again) 545 AmIUsingBindVariables? 562 BindVariablesandParsingWrap‐Up 565 SQL_TRACE,TIMED_STATISTICS,andTKPROF 565 SettingUpTracing 566 UsingandInterpretingTKPROFOutput 569 UsingandInterpretingRawTraceFiles 580 Expert one-on-one Oracle 8 SQL_TRACE,TIMED_STATISTICS,andTKPROFWrap‐Up 593 DBMS_PROFILER 594 Instrumentation 594 StatsPack 597 SettingupStatsPack 597 StatsPackWrap‐Up 618 V$Tables 619 V$EVENT_NAME 619 V$FILESTATandV$TEMPSTAT 620 V$LOCK 620 V$MYSTAT 620 V$OPEN_CURSOR 622 V$PARAMETER 623 V$SESSION 623 V$SESSION_EVENT 626 V$SESSION_LONGOPS 627 V$SESSION_WAIT 627 V$SESSTAT 627 V$SESS_IO 627 V$SQL,V$SQLAREA 627 V$STATNAME 628 V$SYSSTAT 628 V$SYSTEM_EVENT 628 Summary 628 Chapter11:OptimizerPlanStability 630 Overview 630 AnOverviewoftheFeature 630 UsesofOptimizerPlanStability 634 AMethodtoImplementTuning 634 ADevelopmentTool 640 ToSeetheIndexesUsed 642 ToSeewhatSQLisExecutedbyanApplication 642 HowOptimizerPlanStabilityWorks 643 OUTLINESandOUTLINE_HINTS 643 CreatingStoredOutlines 646 PrivilegesNeededforStoredOutlines 646 UsingDDL 647 UsingALTERSESSION 648 TheOUTLNUser 649 MovingOutlinesfromDatabasetoDatabase 650 GettingJusttheRightOutline 651 ManagingOutlines 654 ViaDDL 654 Expert one-on-one Oracle 9 TheOUTLN_PKGPackage 657 Caveats 661 OutlineNamesandCase 661 ALTERSESSIONIssue 663 DROPUSERdoesnotDropOutlines 663 ʹCURSOR_SHARING=FORCEʹandOutlines 664 OutlinesUseSimpleTextMatching 665 OutlinesbyDefaultareintheSYSTEMTablespace 666 OR‐Expansion 666 Performance 667 TheNamespaceofOutlinesisGlobal 672 ErrorsyouMightEncounter 673 ORA‐18001ʺnooptionsspecifiedforALTEROUTLINEʺ 673 ORA‐18002ʺthespecifiedoutlinedoesnotexistʺ 674 ORA‐18003ʺanoutlinealreadyexistswiththissignatureʺ 674 ORA‐18004ʺoutlinealreadyexistsʺ 674 ORA‐18005‐18007 674 Summary 675 Chapter12:AnalyticFunctions 676 Overview 676 AnExample 676 HowAnalyticFunctionsWork 681 TheSyntax 681 TheFunctions 698 Examples 702 TheTOP‐NQuery 702 PivotQuery 714 AccessingRowsAroundYourCurrentRow 723 Caveats 728 PL/SQLandAnalyticfunctions 728 AnalyticFunctionsintheWhereClause 730 NULLSandSorting 731 Performance 733 Summary 734 Chapter13:MaterializedViews 735 Overview 735 ABriefHistory 735 WhatyouʹllneedtoruntheExamples 737 AnExample 737 UsesofMaterializedViews 745 HowMaterializedViewsWork 745 SettingUp 746 InternalMechanics 747 Expert one-on-one Oracle 10 MakingsureyourViewgetsused 750 Constraints 750 Dimensions 756 DBMS_OLAP 767 EstimatingSize 767 DimensionValidation 769 RecommendingMaterializedViews 772 Caveats 774 MaterializedViewsareNotDesignedforOLTPSystems 774 QueryRewriteIntegrity 774 Summary 775 Chapter14:Partitioning 777 Overview 777 TheUsesofPartitioning 777 IncreasedAvailability 777 ReducedAdministrativeBurden 780 EnhancedDMLandQueryPerformance 781 HowPartitioningWorks 783 TablePartitioningSchemes 784 PartitioningIndexes 789 Summary 813 Chapter15:AutonomousTransactions 814 Overview 814 AnExample 814 WhyUseAutonomousTransactions? 817 AuditingthatCanNotbeRolledBack 817 AMethodtoAvoidaMutatingTable 821 PerformingDDLinTriggers 822 WritingtotheDatabase 828 ToDevelopMoreModularCode 839 HowTheyWork 839 TransactionalControl 840 Scope 842 EndinganAutonomousTransaction 849 Savepoints 850 Caveats 853 NoDistributedTransactions 853 PL/SQLOnly 853 TheEntireTransactionRollsBack 853 Transaction‐LevelTemporaryTables 855 MutatingTables 857 ErrorsYouMightEncounter 860 ORA‐06519ʺactiveautonomoustransactiondetectedandrolledbackʺ 860 [...]... 33 Expert one-on-one Oracle   you will find that in order to drop it, you need to:  tkyte@TKYTE816> drop java source ʺdemoʺ;        Java dropped.  Remember to use the double quotes around the identifier for Java objects as they are  created and stored in mixed case.  34 Expert one-on-one Oracle Chapter 1: Developing Successful Oracle Applications  Overview  I spend the bulk of my time working with Oracle database software and, more to the point, ... Chapter 3, Locking and Concurrency.  Different databases have different ways of  doing things (what works well in SQL Server may not work as well in Oracle)  and  21 Expert one-on-one Oracle understanding how Oracle implements locking and concurrency control is  absolutely vital to the success of your application.  This chapter discussed Oracle s basic approach to these issues, the types of locks  that can be applied (DML, DDL, latches ) and the problems that can arise if locking ... Add an Erratum 1541 How to Tell Us Exactly What You Think 1543 17 Expert one-on-one Oracle Introduction  The inspiration for the material contained in this book comes from my experiences  developing Oracle software and working with fellow Oracle developers, helping them  build reliable and robust applications based on the Oracle database. The book is basically a  reflection of what I do everyday and of the issues I see people encountering each and ... not referring to bugs, but really the way it is supposed to work and what the feature was  really designed to do).  18 Expert one-on-one Oracle Who Should Use this Book?  The target audience for this book is anyone who develops applications with Oracle as the  database backend. It is a book for professional Oracle developers who need to know how  to get things done in the database. The practical nature of the book means that many ... the other 10,000 to 20,000 pages of documentation are for) but it will educate you on all of  the important concepts. This manual touches the following topics (to name a few):  19 Expert one-on-one Oracle • • • • • • • • • • • The structures in the database, how data is organized and stored.   Distributed processing.   Oracle s memory architecture.   Oracle s process architecture.   Schema objects you will be using (tables, indexes, clusters, and so on).   Built‐in data types and user‐defined data types.  ... things to be very cut and dry; in other words, easy. Oracle presents the developer with  almost unlimited choice. No one ever says ʹyou canʹt do that in Oracle ‐ they say ʹhow  many different ways would you like to do that in Oracle? ʹ I hope that this book will help  you make the correct choice.  It is a book for those people who appreciate the choice but would also like some guidelines  and practical implementation details on Oracle features and functions. For example, ... Caveats of using this feature  20 Expert one-on-one Oracle Handling errors (proactively)   • A summary to bring it all together.   There will be lots of examples, and lots of code, all of which will be available for download  at http://www.apress.com/ Following is a detailed breakdown of the content of each  section:  Understanding the Database  • Chapter 1, Developing Successful Oracle Applications.  This chapter sets out my ... Appendix AH: DBMS_LOGMNR 1339 Overview 1339 15 Expert one-on-one Oracle Overview 1341 Step 1: Creating the Data Dictionary 1341 Step 2: Using Log Miner 1345 Options and Usage 1352 Using Log Miner to Find Out When .1355 PGA Usage 1357 Log Miner Limits 1359 Oracle Object Types 1359 Chained or Migrated Rows ... Chapter 12, Analytic Functions.  Certain questions are asked of the database very  regularly, but the queries that can answer them are difficult to write in straight SQL  23 Expert one-on-one Oracle • • • • (and will not always perform quickly, anyway). Oracle 8.1.6 introduced analytic  functions. These functions add extensions to the SQL language that make such  queries easier to code, and dramatically increase performance over the equivalent ... Web, which gives rise to situations where your client presents their credentials to a  middle‐tier application server, before actually accessing your database. We will see  25 Expert one-on-one Oracle • how this feature can be implemented and how it works. We will look at how you  can grant privileges and audit proxy accounts.   Chapter 23, Invoker and Definer Rights.  Starting with Oracle 8i, we can now  grant a different set of privileges to different users of a stored procedure. With  .  WWW.EBOOKWORLD.CO.NR Expert one-on-one Oracle 2   This page intentionally left blank Expert one-on-one Oracle 3 Content Introduction 18 WhatthisBookisAbout. 1543 Expert one-on-one Oracle 18 Introduction Theinspirationforthematerialcontainedinthisbookcomesfrommyexperiences developing Oracle softwareandworkingwithfellow Oracle developers,helpingthem buildreliableandrobustapplicationsbasedonthe Oracle database.Thebookisbasicallya reflectionofwhatIdoeverydayandoftheissuesIseepeopleencounteringeachand everyday. IcoveredwhatIfeltwasmostrelevant‐namelythe Oracle databaseanditsarchitecture.I couldhavewrittenasimilarly‐titledbookexplaininghowtodevelopanapplicationusing aspecificlanguageandarchitecture‐forexample,oneusingJavaServerPagesthatspeak toEnterpriseJavaBeans,thatuseJDBCtocommunicatewith Oracle. However,attheend oftheday,youreallydoneedtounderstandthetopicscoveredhereinordertobuildsuch anapplicationsuccessfully.ThisbookdealswithwhatIbelieveneedstobeuniversally knowntodevelopsuccessfullywith Oracle, whetheryouareaVisualBasicprogrammer usingODBC,aJavaprogrammerusingEJBsandJDBC,oraPerlprogrammerusingDBI Perl.Thisbookdoesnotpromoteanyspecificapplicationarchitecture;itdoesnotcompare 3‐tiertoclient‐server.Rather,itcoverswhatthedatabasecandoandwhatyoumust understandaboutthewayitworks.Sincethedatabaseisattheheartofanyapplication architecture,thebookshouldhaveabroadaudience. WhatthisBookisAbout Oneoftheproblemswithhavingplentyofdevelopmentoptionsisintryingtofigureout whichonemightbethebestchoiceforyourparticularneeds.Everyonewantsasmuch flexibilityaspossible(asmanychoicesastheycanpossiblyhave)buttheyalsowant thingstobeverycutanddry;inotherwords,easy. Oracle presentsthedeveloperwith almostunlimitedchoice.NooneeversaysʹyoucanʹtdothatinOra. Familiaritywiththe Oracle ServerConceptsManual. Afewwordsonthatlastpoint:duetoitsvastsize,manypeoplefindthe Oracle documentationsettobesomewhatintimidating.Ifyouarejuststartingoutorhavenʹtread anyofitasyet,Icantellyouthatthe Oracle8 iConceptsmanualisexactlytherightplaceto start.Itisabout800pageslongandtouchesonmanyofthemajor Oracle conceptsthat youneedtoknowabout.Itmaynotgiveyoueach,andeverytechnicaldetail(thisiswhat theother10,000to20,000pagesofdocumentationarefor)butitwilleducateyouonallof theimportantconcepts.Thismanualtouchesthefollowingtopics(tonameafew): Expert one-on-one Oracle 20 • Thestructuresinthedatabase,howdataisorganizedandstored. • Distributedprocessing. • Oracle smemoryarchitecture. • Oracle sprocessarchitecture. •

Ngày đăng: 07/04/2014, 15:47

TỪ KHÓA LIÊN QUAN