Download presentation/whitepaper

496 views
451 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
496
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Download presentation/whitepaper

  1. 2. Steve George Sr. Delivery Manager Oracle University Oracle Corporation
  2. 3. Tips, tricks and Techniques for the Oracle Database
  3. 4. Overview <ul><li>This course concentrates on Oracle9 i Release 2 new features applicable to database administration </li></ul><ul><li>Previous experience with Oracle databases is required for a full understanding of many new features, particularly Oracle8 and Oracle8 i </li></ul>
  4. 5. Displaying Execution Plans SQL*Plus Autotrace <ul><li>Create the plan_table table. </li></ul><ul><li>Create and grant the plustrace role. </li></ul><ul><li>Autotrace syntax: </li></ul>SQL> @$ORACLE_HOME/sqlplus/admin/plustrce.sql SQL> GRANT plustrace TO scott; SET AUTOTRACE [ Off | On | Traceonly ] [ Explain | Statistics ]
  5. 6. Generate the Execution Plan <ul><li>Can be used without tracing </li></ul><ul><li>Needs the plan_table table utlxplan.sql </li></ul><ul><li>Create the explain plan: </li></ul>SQL> EXPLAIN PLAN FOR 2 SELECT last_name FROM hr.employees;
  6. 7. Query the plan_table Table Using dbms_xplan.display <ul><li>Query plan_table to display the execution plans: </li></ul><ul><ul><li>Query plan_table directly. </li></ul></ul><ul><ul><li>Use script utlxpls.sql (hide Parallel Query information). </li></ul></ul><ul><ul><li>Use script utlxplp.sql (show Parallel Query information). </li></ul></ul><ul><ul><li>Use the dbms_xplan package. </li></ul></ul>SQL> SELECT * 2 FROM TABLE(dbms_xplan.display);
  7. 8. Metadata API in Oracle9 i <ul><li>A new package, DBMS_METADATA , is introduced. </li></ul><ul><li>Using this package, you can extract metadata in: </li></ul><ul><ul><li>Browsing mode , or </li></ul></ul><ul><ul><li>Programmatic mode where the program can specify: </li></ul></ul><ul><ul><ul><li>The types of objects to be retrieved </li></ul></ul></ul><ul><ul><ul><li>Various selection criteria </li></ul></ul></ul><ul><ul><ul><li>Transformation of the output by default is XML , but can be of any format (uses XSL) . </li></ul></ul></ul>
  8. 9. Metadata API in Oracle9 i Browsing Example <ul><li>The query can have a WHERE clause. </li></ul><ul><li>Output is in SQL, but can be in XML format. </li></ul><ul><li>Combine with a SPOOL statement for XML file </li></ul><ul><li>Any combination of objects can be extracted, depending on the result of the SELECT statement. </li></ul><ul><li>Running a spool while extracting provides a file that can be edited immediately. </li></ul>SQL> SELECT dbms_metadata.get_ddl ('TABLE','SALES') 2 FROM dual;
  9. 10. Default Partition for List Partitioning <ul><li>Create a DEFAULT partition for all values not covered by other list partitions: </li></ul>CREATE TABLE customer ... PARTITION BY LIST (state) (PARTITION p1 VALUES ('CA','CO'), PARTITION p2 VALUES ('FL','TX'), PARTITION p3 VALUES ( DEFAULT ) );
  10. 11. Range List Composite Partitioning List (state) Range (month) CREATE TABLE customer ... PARTITION BY RANGE (month) SUBPARTITION BY LIST (state) ...; p1_s1 p1_s2 p1_s3 p2_s1 p2_s2 p2_s3 p3_s1 p3_s2 p3_s3 p4_s1 p4_s2 p4_s3 < 3 < 6 < 9 < 12 'CA', 'CO' Default 'FL', 'TX'
  11. 13. Composite Partitioning Using a Template <ul><li>Use a subpartition template for: </li></ul><ul><ul><li>Range list partitions </li></ul></ul><ul><ul><li>Range hash partitions </li></ul></ul>CREATE TABLE state_sales ... PARTITION BY RANGE (month) SUBPARTITION BY LIST (state) SUBPARTITION TEMPLATE (SUBPARTITION s1 VALUES ('CA,''CO') SUBPARTITION s2 VALUES ('FL','TX') ) ...
  12. 14. Rename Columns and Constraints SQL> ALTER TABLE employees 2 RENAME COLUMN salary TO sal; SQL> ALTER TABLE employees 2 RENAME CONSTRAINT sys_c002691 3 TO pk_employees_id;
  13. 15. RMAN: Control Archived Log Space Usage <ul><li>Avoid errors caused by insufficient disk space for restored archived logs during recovery </li></ul><ul><li>Define size available for storage of archived logs copied to disk from backup sets </li></ul><ul><li>Use MAXSIZE option in conjunction with DELETE option </li></ul>RMAN> RECOVER DATABASE 2> DELETE 3> ARCHIVELOG MAXSIZE 100K;
  14. 16. Backing Up the Server Parameter File <ul><ul><li>Automatically backed up when CONFIGURE CONTROLFILE AUTOBACK = ON </li></ul></ul><ul><ul><li>Explicitly backed up with BACKUP SPFILE </li></ul></ul>RMAN> BACKAUP COPIES 2 DEVICE TYPE sbt SPFILE; RMAN> BACKUP SPFILE;
  15. 17. Persistent Configuration Parameters <ul><li>Customizable configuration parameters simplify RMAN operations. </li></ul><ul><li>Default settings are set once and used for subsequent jobs. </li></ul><ul><li>A DBA can invoke RMAN and back up a database with one command: BACKUP DATABASE . </li></ul><ul><li>Oracle9 i provides the new CONFIGURE command to override default settings persistently. </li></ul><ul><li>The configuration values are stored in the control file and are resynchronized to the recovery catalog as necessary. </li></ul>
  16. 18. Automatic Channel Allocation <ul><li>This feature applies to BACKUP , COPY , and RESTORE commands. </li></ul><ul><li>A channel is automatically allocated if one is not explicitly specified in the RMAN command. </li></ul><ul><li>Default values are specified with the CONFIGURE command. </li></ul><ul><li>The benefit of this feature is a usability improvement due to the simplification of subsequent commands. </li></ul>
  17. 19. CONFIGURE CHANNEL Command <ul><li>Used to configure settings that will be used for the channels (all or individual): </li></ul>CONFIGURE CHANNEL [n] <channel_option_list>; channel_option_list := TYPE, NAME, PARMS, CONNECT STRING, DEBUG, FORMAT, TRACE, MAXPIECESIZE, RATE, MAXOPENFILES, SEND
  18. 21. Enterprise Manager Backup Wizard
  19. 22. Backup Wizard: Deletion of Archived Logs
  20. 23. Backup Wizard: Override RMAN Configuration
  21. 24. DBNEWID Utility <ul><li>The DBID of a database </li></ul><ul><li>The DBNAME of a database </li></ul><ul><li>Both the DBNAME and DBID of a database </li></ul>d:>nid DBNEWID: Release 9.2.0.1.0 - Production Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. Keyword Description (Default) ---------------------------------------------------- TARGET Username/Password (NONE) DBNAME New database name (NONE) LOGFILE Output Log (NONE) REVERT Revert failed change NO SETNAME Set a new database name only NO APPEND Append to output log NO HELP Displays these messages NO
  22. 25. Shared Pool Advisory SQL> SELECT shared_pool_size_for_estimate AS pool_size, 2 estd_lc_size, estd_lc_time_saved 3 FROM v$shared_pool_advice; POOL_SIZE ESTD_LC_SIZE ESTD_LC_TIME_SAVED --------- ------------ ------------------ 32 8 7868 40 15 7868 48 17 7868 56 17 7868 64 17 7868 72 17 7868 80 17 7868 88 17 7868 96 17 7868
  23. 27. Enterprise Manager Shared Pool Size Advisor
  24. 28. Mean Time To Recover (MTTR) Advisory <ul><li>Collect statistics by setting initialization parameters </li></ul><ul><ul><li>FAST_START_MTTR_TARGET to non-zero value </li></ul></ul><ul><ul><li>STATISTICS_LEVEL to TYPICAL or ALL </li></ul></ul><ul><li>View estimated overhead for different settings of FAST_START_MTTR_TARGET </li></ul><ul><ul><li>In the rows of the view v$mttr_target_advice </li></ul></ul><ul><ul><li>Through the Enterprise Manager graphical interface to this view </li></ul></ul>
  25. 29. View MTTR Advisory with Enterprise Manager
  26. 30. V$PGA_TARGET_ADVICE TARGET_MB CACHE_HIT_PERCENT ESTD_OVERALLOC_COUNT ---------- ----------------- -------------------- 63 23 367 125 24 30 250 30 3 375 39 1 500 58 0 600 59 0 700 59 0 800 60 0 900 60 0 1000 61 0 1500 67 0 2000 76 0 3000 83 0 4000 85 0
  27. 32. PGA Sizing Advice Conclusions LOW_KB HIGH_KB OPTIMAL ONEPASS MPASS ------ ------- ------- ------- ------- 8 16 156107 0 0 16 32 148 0 0 32 64 89 0 0 64 128 13 0 0 128 256 58 0 0 256 512 10 0 0 512 1024 653 0 0 1024 2048 530 0 0 2048 4096 509 0 0 4096 8192 227 0 0 8192 16384 176 0 0 16384 32768 133 14 0 32768 65536 66 103 0 65536 131072 15 47 0 131072 262144 0 48 0 262144 524288 0 23 0
  28. 34. PGA Sizing Advisor Output in Enterprise Manager
  29. 35. Data Compression CREATE TABLE employees( employee_id INTEGER, first_name VACHAR2(20), … ) COMPRESS; CREATE TABLESPACE sample   DATAFILE 'sample01.dbf' SIZE 20M    DEFAULT COMPRESS ; CREATE TABLE countries( country_id CHAR(2), country_name VARCHAR2(40), region_id NUMBER ) NOCOMPRESS TABLESPACE sample;
  30. 37. Data Compression Optimization: Enabling Row Movement CREATE TABLE employees (employee_id NUMBER, first_name VARCHAR2(20), last_name VARCHAR2(30), ...) ENABLE ROW MOVEMENT; ( both partitioned and nonpartitioned )
  31. 38. Locally Managed SYSTEM Tablespace <ul><li>Create databases with a locally managed SYSTEM tablespace: </li></ul>CREATE DATABASE mydb ... DATAFILE ' system01.dbf ' SIZE 100M EXTENT MANAGEMENT LOCAL ...;
  32. 39. Flashback Queries -- Query based on past SCN number: SELECT employee_id, manager_id FROM employees AS OF SCN 81591; -- Find changes made between 1-2 hours ago: SELECT a.last_name, b.last_name FROM employees AS OF TIMESTAMP SYSDATE-1/24 a FULL OUTER JOIN employees AS OF TIMESTAMP SYSDATE-2/24 b ON (a.employee_id = b.employee_id) -- Create new table based on old data: CREATE TABLE new_employees AS SELECT * FROM employees AS OF SCN 90932;
  33. 40. Reminder – please complete the OracleWorld session survey Thank you.
  34. 41. Next Steps…. <ul><li>Be sure to visit the DemoGrounds and see Oracle software and services in action </li></ul><ul><li>Check out Meet the Gurus in the DemoGrounds for your opportunity to meet top Oracle developers </li></ul><ul><li>Attend Mini Theatre presentations relevant to your job role and education needs </li></ul><ul><li>Don’t forget you can take exams onsite for only $50! </li></ul><ul><li>Remember to register for any OU inClass course within 60 days of OracleWorld and receive 15% discount </li></ul>
  35. 42. Next Steps…. <ul><li>See Your Business in Our Software </li></ul><ul><ul><li>Visit the DEMOogrounds for a customized architectural review, see a customized demo with Solutions Factory, or receive a personalized proposal. Visit the DEMOgrounds for more information. </li></ul></ul><ul><li>Relevant web sites to visit for more information </li></ul><ul><ul><li>www.oracle.com/education </li></ul></ul>
  36. 43. Reminder – please complete the OracleWorld session survey Thank you.
  37. 44. A Q & Q U E S T I O N S A N S W E R S

×