Oracle9i Database Administrator: Implementation and Administration 1 Chapter 7 Basic Table Management.

Slides:



Advertisements
Similar presentations
11 Copyright © Oracle Corporation, All rights reserved. Managing Tables.
Advertisements

9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
Data Definition Language (DDL)
The Architecture of Oracle
Oracle 10g Database Administrator: Implementation and Administration Chapter 8 Advanced Table Management.
Primer on Structure& Storage Analysis Primer on Structure & Storage Analysis This presentation is supposed to give a simple and brief overview for storage.
Basic Storage Concepts and Settings
Data archival using Partitioning and Partition Maintenance O/o the A.G.(A&E)-II NagpurMaharashtra.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
IS 4420 Database Fundamentals Chapter 6: Physical Database Design and Performance Leon Chen.
Harvard University Oracle Database Administration Session 5 Data Storage.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Oracle Database Administration Database files Logical database structures.
CHAPTER 11 Large Objects. Need for Large Objects Data type to store objects that contain large amount of text, log, image, video, or audio data. Most.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
9/11/2015ISYS366 - Week051 ISYS366 – Week 5-6 Database Tuning - User and Rollback Data Spaces, Recovery, Backup.
Oracle Data Block Oracle Concepts Manual. Oracle Rows Oracle Concepts Manual.
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 9 Index Management.
7202ICT Database Administration Lecture 7 Managing Database Storage Part 2 Orale Concept Manuel Chapter 3 & 4.
Extents, segments and blocks in detail. Database structure Database Table spaces Segment Extent Oracle block O/S block Data file logical physical.
1 of 31 Title Slide Learn How To Partition In Oracle 9i Release 2 Reference Number: #31316 By Eric Yen System Consultant Quest Software.
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
9 Storage Structure and Relationships. 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating.
10 Copyright © 2009, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
1 Copyright © 2006, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Sizing Basics  Why Size?  When to size  Sizing issues:  Bits and Bytes  Blocks (aka pages) of Data  Different Data types  Row Size  Table Sizing.
3 Copyright © 2005, Oracle. All rights reserved. Partitioning Basics.
Lecture 2: Using DDL Statements to Create and Manage Tables & Indexes
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Database Application Development using PL/SQL Programming.
Oracle 10g Database Administrator: Implementation and Administration Chapter 7 Basic Table Management.
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
6 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
8 Copyright © 2007, Oracle. All rights reserved. Managing Schema Objects.
Week 3 Lecture 2 Basic Storage Concepts and Settings.
14 Copyright © 2006, Oracle. All rights reserved. Tuning Block Space Usage.
5 Copyright © 2005, Oracle. All rights reserved. Managing Database Storage Structures.
Oracle 9i Release 2, A new set of tips, tricks and Techniques. Steve George Sr. Delivery Manager – Oracle University Oracle Corporation Session id: #32681.
Week 4 Lecture 2 Advanced Table Management. Learning Objectives  Create tables with large object (LOB) columns and tables that are index-organized 
8 Copyright © 2004, Oracle. All rights reserved. Managing Schema Objects.
Harvard University Oracle Database Administration Session 6 Object Storage.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Chapter 4 Logical & Physical Database Design
Managing Schema Objects
IT Database Administration Section 07. Space Management Managing Space: An Introduction  Organizing database storage is a major responsibility.
Chapter 5 Index and Clustering
Indexes … WHERE key = Table Index 22 Row pointer Key Indexes
Data Warehousing Seminar Chapter 13 Indexing the Warehouse
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
1 Comparison between Oracle and Teradata Center of Excellence Data Warehousing Wipro Technologies.
Unit 6 Seminar. Indexed Organized Tables Definition: Index Organized Tables are tables that, unlike heap tables, are organized like B*Tree indexes.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
1 Part IV: Object-Relational Databases  Ch. 30: Types, Object Views, Methods  Ch. 31: Nested Tables and Varying Arrays  Ch. 32: Large Objects  Ch.
Select Operation Strategies And Indexing (Chapter 8)
7 Copyright © 2004, Oracle. All rights reserved. Managing Schema Objects.
8 Copyright © Oracle Corporation, All rights reserved. Managing Tablespaces and Data files.
1 Chapters 19 and 20  Ch. 19: By What Authority? Users Roles Grant and revoke Synonyms  Ch. 20: Changing the Oracle Surroundings Indexes Clusters Sequences.
Fundamentals of DBMS Notes-1.
Introduction To Oracle
Database structure and space Management
Database Tuning - User and Rollback Data Spaces, Recovery, Backup
Storage Structure and Relationships
DATABASE MANAGEMENT SYSTEM
Database structure and space Management
Introduction To Oracle 10g
Storage Structure and Relationships
Managing Tables.
IST 318 Database Administration
Presentation transcript:

Oracle9i Database Administrator: Implementation and Administration 1 Chapter 7 Basic Table Management

Oracle9i Database Administrator: Implementation and Administration 2 Objectives  Describe the different types of tables and their storage methods  Create relational and temporary tables  Create tables containing varrays and nested tables  Create object and partitioned tables

Oracle9i Database Administrator: Implementation and Administration 3 Introduction to Table Structures Table types:  Relational  Index-organized  Object  Temporary  External  Nested  XML  Cluster

Oracle9i Database Administrator: Implementation and Administration 4 Setting Block Space Usage Syntax of the CREATE TABLE command: CREATE TABLE ( ) TABLESPACE STORAGE ( ) Area of focus in this chapter

Oracle9i Database Administrator: Implementation and Administration 5 Setting Block Space Usage Expanded STORAGE clause syntax: TABLESPACE STORAGE (INITIAL NEXT PCTINCREASE MINEXTENTS MAXEXTENTS FREELISTS FREELIST GROUPS BUFFER_POOL KEEP|RECYCLE|DEFAULT) PCTFREE PCTUSED INITRANS MAXTRANS INITIAL: Size of the first extent NEXT: Size of next and all subsequent extents PCTINCREASE: Range of 0 to 100 Percent of previous extent to increase each subsequent extent

Oracle9i Database Administrator: Implementation and Administration 6 Setting Block Space Usage Expanded STORAGE clause syntax: TABLESPACE STORAGE (INITIAL NEXT PCTINCREASE MINEXTENTS MAXEXTENTS FREELISTS FREELIST GROUPS BUFFER_POOL KEEP|RECYCLE|DEFAULT) PCTFREE PCTUSED INITRANS MAXTRANS MINEXTENTS: Min. number of extents MAXEXTENTS: Max. number of extents Primarily for Real Application Clusters FREELISTS: Number of freelists per extent FREELIST GROUPS: Number of freelist groups per extent

Oracle9i Database Administrator: Implementation and Administration 7 Setting Block Space Usage Expanded STORAGE clause syntax: TABLESPACE STORAGE (INITIAL NEXT PCTINCREASE MINEXTENTS MAXEXTENTS FREELISTS FREELIST GROUPS BUFFER_POOL KEEP|RECYCLE|DEFAULT) PCTFREE PCTUSED INITRANS MAXTRANS BUFFER POOL: buffer area in which data blocks from the table are stored in the SGA PCTFREE: Minimum percent of data block reserved for updates PCTUSED: Percent of data block used below which block is re-opened for updates

Oracle9i Database Administrator: Implementation and Administration 8 Setting Block Space Usage Expanded STORAGE clause syntax: TABLESPACE STORAGE (INITIAL NEXT PCTINCREASE MINEXTENTS MAXEXTENTS FREELISTS FREELIST GROUPS BUFFER_POOL KEEP|RECYCLE|DEFAULT) PCTFREE PCTUSED INITRANS MAXTRANS Initial and maximum number of transactions that can concurrently access a data block

Oracle9i Database Administrator: Implementation and Administration 9 Setting Block Space Usage Data block components Arrows indicate direction of growth

Oracle9i Database Administrator: Implementation and Administration 10 Setting Block Space Usage Overhead: Grows when more rows are inserted Grows when INITRANS or MAXTRANS are increased Never shrinks

Oracle9i Database Administrator: Implementation and Administration 11 Setting Block Space Usage Free space: Cannot insert rows if free space exceeds PCTFREE Cannot update rows if no free space left Can resume inserting rows if used space falls below PCTUSED

Oracle9i Database Administrator: Implementation and Administration 12 Setting Block Space Usage Row data: Grows when rows are inserted or updated Shrinks when rows are deleted or updated

Oracle9i Database Administrator: Implementation and Administration 13 Setting Block Space Usage When a single row spans two data blocks: Chained row Migrated row

Oracle9i Database Administrator: Implementation and Administration 14 Storage Methods Options when setting storage for a table:  Use tablespace defaults  Customize the STORAGE clause for each table  Use Oracle defaults

Oracle9i Database Administrator: Implementation and Administration 15 Storage Methods: How to Set Storage For Locally Managed Tables Simplified syntax: TABLESPACE STORAGE (INITIAL )  Example : CREATE TABLE CH07BICYCLE (BIKE_ID NUMBER(10) PRIMARY KEY, BIKE_MAKER VARCHAR2(50) NOT NULL, STYLE VARCHAR2(15)) TABLESPACE USERS STORAGE (INITIAL 25M);

Oracle9i Database Administrator: Implementation and Administration 16 Storage Methods: How to Set Storage For Dictionary-Managed Tables Example (customize storage for table) : CREATE TABLE TRUCK_MAINTENANCE (TRUCK_ID NUMBER(10), REPAIR_DATE DATE, PROBLEM_DESCRIPTION VARCHAR2(2000), DIAGNOSIS VARCHAR2(2000), BILLING_DATE DATE, BILLING_AMT NUMBER (10,2)) TABLESPACE USER_DTAB STORAGE (INITIAL 80M NEXT 40M PCT INCREASE 0 MINEXTENTS 2 MAXEXTENTS 25) PCTFREE 25 PCTUSED 50 MINTRANS 1 MAXTRANS 2;

Oracle9i Database Administrator: Implementation and Administration 17 Storage Methods: How to Set Storage For Dictionary-Managed Tables Example (use tablespace defaults) : CREATE TABLE BIKE_MAINTENANCE (BIKE_ID NUMBER(10), REPAIR_DATE DATE, DESCRIPTION VARCHAR2(30));

Oracle9i Database Administrator: Implementation and Administration 18 Row Structure and the ROWID Row components: Row header Column Data

Oracle9i Database Administrator: Implementation and Administration 19 Row Structure and the ROWID Physical rowid: Used for most tables Never changes once the row is created Subtypes: Extended: Default Restricted: Old format Logical rowid: Identifies row by primary key value Used for index-organized tables

Oracle9i Database Administrator: Implementation and Administration 20 Row Structure and the ROWID Internal format of each rowid type

Oracle9i Database Administrator: Implementation and Administration 21 Creating Tables Expanded syntax: CREATE TABLE. ( NULL|NOT NULL DEFAULT CHECK,... ) TABLESPACE STORAGE (INITIAL NEXT PCTINCREASE MINEXTENTS MAXEXTENTS FREELISTS FREELIST GROUPS BUFFER_POOL KEEP|RECYCLE|DEFAULT) PCTFREE PCTUSED INITRANS MAXTRANS

Oracle9i Database Administrator: Implementation and Administration 22 Creating Tables: Columns and Data Types Datatypes: Character types: CHAR, VARCHAR, VARCHAR2 NCHAR, NVARCHAR, NVARCHAR2 LONG Number type: NUMBER

Oracle9i Database Administrator: Implementation and Administration 23 Creating Tables: Columns and Data Types Datatypes: Date and time types: DATE, TIMESTAMP TIMESTAMP WITH TIME ZONE TIMESTAMP WITH LOCAL TIME ZONE INTERVAL YEAR TO MONTH INTERVAL DAY TO SECOND LOB BLOB, CLOB, NCLOB, BFILE New in Oracle9i

Oracle9i Database Administrator: Implementation and Administration 24 Creating Tables: Columns and Data Types Raw: RAW, LONG RAW Rowid: ROWID, UROWID Collection: VARRAY NESTED TABLE Object data types: REF User-defined data type

Oracle9i Database Administrator: Implementation and Administration 25 Creating Relational Tables Factors in relational table design: Name of the table Name and data type of all columns Estimated initial size and growth pattern Location of the table Constraints, relationships to other tables, default data

Oracle9i Database Administrator: Implementation and Administration 26 Creating Relational Tables Example: CREATE TABLE EMPLOYEE (EMPLOYEE_ID NUMBER (10), JOB_TITLE VARCHAR2(45), first_name varchar2(40), Last_name varchar2(40), phone_number Varchar2(20)); Storage settings used: TABLESPACE: User's default tablespace SYSTEM, if no user default Each STORAGE setting: The tablespace's default storage setting Oracle default, if no tablespace default setting

Oracle9i Database Administrator: Implementation and Administration 27 Creating Temporary Tables Example: CREATE GLOBAL TEMPORARY TABLE EDITOR_REVENUE ON COMMIT PRESERVE ROWS AS SELECT E.FIRST_NAME || ' ' || E.LAST_NAME EDITOR, SUM(CA.PRICE) ANNUAL_REVENUE FROM CLASSIFIED_AD CA JOIN EMPLOYEE E ON (CA.INTAKE_EDITOR_ID = E.EMPLOYEE_ID) WHERE TO_CHAR(CA.PLACED_DATE, 'YYYY') = '2003' GROUP BY FIRST_NAME || ' ' || LAST_NAME; Alternative: ON COMMIT DELETE ROWS

Oracle9i Database Administrator: Implementation and Administration 28 Creating Varrays and Nested Tables

Oracle9i Database Administrator: Implementation and Administration 29 Creating Varrays and Nested Tables Example of nested table: CREATE TABLE CLASSIFIED_SECTION (SECTION_NO NUMBER NOT NULL, SECTION_TITLE VARCHAR2(50), BASE_RATE_PER_WORD NUMBER(4,3), CONTACT_EDITOR CLASSMATE.CONTACT_TABLE) NESTED TABLE CONTACT_EDITOR STORE AS NESTED_EDITORS; Nested table data stored in out of line table User-defined table type

Oracle9i Database Administrator: Implementation and Administration 30 Creating Varrays and Nested Tables Varrays: Contain finite lists of data Are stored inside the table

Oracle9i Database Administrator: Implementation and Administration 31 Creating Varrays and Nested Tables Nested tables: Contain unlimited rows of data Are stored out of line from the table

Oracle9i Database Administrator: Implementation and Administration 32 Creating Object Tables Same storage settings as relational tables Example: CREATE TABLE CUSTOMER_ADDRESS OF CUSTOMER_ADDRESS_TYPE; Object type datatype

Oracle9i Database Administrator: Implementation and Administration 33 Creating Partitioned Tables Allows one table to span multiple tablespaces Intended for very large tables Each partition can have its own storage settings Types of partitions:  Range  Hash  List  Composite range-hash  Composite range-list

Oracle9i Database Administrator: Implementation and Administration 34 Range Partitioning Designate a range of values Specify one or multiple columns Example: CREATE TABLE TRANSACTION_RECORD ( ACCT_NO NUMBER NOT NULL, …) PARTITION BY RANGE (ACCT_NO) ( PARTITION TRANS_P1 VALUES LESS THAN ( ) TABLESPACE TBS1, PARTITION TRANS_P2 VALUES LESS THAN ( ) TABLESPACE USER_DATA, PARTITION TRANS_P3 VALUES LESS THAN ( ) TABLESPACE USER_ALT); Partition key Range Storage

Oracle9i Database Administrator: Implementation and Administration 35 Hash Partitioning Supplies an even distribution to data rows to spread the I/O load across devices Specify one or multiple columns Example: CREATE TABLE MORTGAGE_HISTORY (LOAN_NO NUMBER, ACCT_NO NUMBER, DATE_CREATED DATE, MORTGAGE_AMOUNT NUMBER) PARTITION BY HASH (DATE_CREATED) PARTITIONS 3 STORE IN (HISTORY_TBSP1, HISTORY2, HISTORYEXTENDED); Partition key Number of partitions Storage

Oracle9i Database Administrator: Implementation and Administration 36 List Partitioning Similar to range, but specify exact values instead of ranges Can use only one column Example: CREATE TABLE TRANS_BY_BRANCH_HISTORY (BRANCH_ID NUMBER(9,0), BRANCH_REGION VARCHAR2(10), …) PARTITION BY LIST (BRANCH_REGION) (PARTITION WESTERN VALUES ('WESTCOAST', 'NORTHWEST') TABLESPACE HIST3, PARTITION MOUNTAIN VALUES ('ROCKIES', 'SOUTHWEST') TABLESPACE HIST3, PARTITION MIDWEST VALUES ('MIDWEST', 'IL-METRO') STORAGE (INITIAL 20M NEXT 40M PCTINCREASE 20) TABLESPACE HIST1; Storage Partition key List values

Oracle9i Database Administrator: Implementation and Administration 37 Composite Range-hash Partitioning Partition by range Sub-partition each partition by hash values Example: CREATE TABLE TRANSACTION_RECORD ( ACCT_NO NUMBER NOT NULL, ACTION VARCHAR2(5) NOT NULL, AMOUNT NUMBER(8,2) NOT NULL, SENDING_ACCT_NO NUMBER NOT NULL, ACTION_DATE DATE NOT NULL ) PARTITION BY RANGE (ACCT_NO) SUBPARTITION BY HASH (ACTION_DATE) SUBPARTITIONS 8 STORE IN (TBS1, USER_DATA, USER_ALT, USER_ALT2) PARTITION TRANS_P1 VALUES LESS THAN ( ), PARTITION TRANS_P2 VALUES LESS THAN ( ), PARTITION TRANS_P3 VALUES LESS THAN ( )); Storage Partition key Sub-partition key Number of Sub-part. Range values

Oracle9i Database Administrator: Implementation and Administration 38 Composite Range-list Partitioning Partition by range Sub-partition each partition by list of values Example: CREATE TABLE TRANSACTION_RECORD ( ACCT_NO NUMBER NOT NULL, ACTION …) PARTITION BY RANGE (ACCT_NO) SUBPARTITION BY LIST (ACTION) SUBPARTITION TEMPLATE (SUBPARTITION WESTERN VALUES ('WESTCOAST', 'NORTHWEST'), SUBPARTITION MOUNTAIN VALUES ('ROCKIES', 'SOUTHWEST')) (PARTITION TRANS_P1 VALUES LESS THAN ( ) TABLESPACE HIST3, PARTITION TRANS_P2 VALUES LESS THAN ( ) TABLESPACE HIST2); Storage Partition key Sub-partition key Sub-part. template Sub-part. list values Range values

Oracle9i Database Administrator: Implementation and Administration 39 Chapter Summary Relational tables reside in a single segment within a single tablespace, unless the table is partitioned A temporary table, which is seen only by one user, is created for private data Tables can use the default storage settings of the tablespace or use their own settings Chained rows and migrated rows slow down performance speed

Oracle9i Database Administrator: Implementation and Administration 40 Chapter Summary A row is made up of a row header and column data A rowid can be physical or logical Relational tables can be defined as a list of columns or as a subquery Varrays and nested tables are like tables within one column of another table

Oracle9i Database Administrator: Implementation and Administration 41 Chapter Summary Nested table data is stored out of line (in a separate location) from the primary table A partition of a table resides in its own segment Partitioning can be done with range, list, hash, or composite methods