Week 4 Lecture 2 Advanced Table Management. Learning Objectives  Create tables with large object (LOB) columns and tables that are index-organized 

Slides:



Advertisements
Similar presentations
CHAPTER 4 Tablespaces and Datafiles. Introduction After installing the binaries, creating a database, and configuring your environment, the next logical.
Advertisements

11 Copyright © Oracle Corporation, All rights reserved. Managing Tables.
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)
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
Oracle Online Features - Golfing Instead of Working on Weekends Oracle World 2003 – Session Sep 2003 Denny Wong Consultant Database Services.
12 Copyright © Oracle Corporation, All rights reserved. Managing Indexes.
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.
Harvard University Oracle Database Administration Session 5 Data Storage.
Oracle Data Definition Language (DDL)
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
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.
IT Database Administration Section 03. Tablespaces and the DBA  Important for DBAs – logical units of database storage Made up of physical operating-system.
9/11/2015ISYS366 - Week051 ISYS366 – Week 5-6 Database Tuning - User and Rollback Data Spaces, Recovery, Backup.
Database Administration TableSpace & Data File Management
Chapter 6 Additional Database Objects
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.
CHAPTER 7 Tables and Constraints. Logical Progression of Steps in Creating a Database Environment 1. Install Oracle database binaries (Chapter 1) 2. Create.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
9 Storage Structure and Relationships. 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating.
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 7 Basic Table Management.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
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.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Week 3 Lecture 2 Basic Storage Concepts and Settings.
14 Copyright © 2006, Oracle. All rights reserved. Tuning Block Space Usage.
Harvard University Oracle Database Administration Session 6 Object Storage.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Oracle 10g Database Administrator: Implementation and Administration Chapter 5 Basic Storage Concepts and Settings.
Managing Schema Objects
IT Database Administration Section 07. Space Management Managing Space: An Introduction  Organizing database storage is a major responsibility.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
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
Chapter 3 Table Creation and Management Oracle 10g: SQL.
1 Part IV: Object-Relational Databases  Ch. 30: Types, Object Views, Methods  Ch. 31: Nested Tables and Varying Arrays  Ch. 32: Large Objects  Ch.
1 11g NEW FEATURES ByVIJAY. 2 AGENDA  RESULT CACHE  INVISIBLE INDEXES  READ ONLY TABLES  DDL WAIT OPTION  ADDING COLUMN TO A TABLE WITH DEFAULT VALUE.
 CONACT UC:  Magnific training   
8 Copyright © 2007, Oracle. All rights reserved. Implementing SecureFile LOBs.
8 Copyright © Oracle Corporation, All rights reserved. Managing Tablespaces and Data files.
2 Copyright © 2009, Oracle. All rights reserved. Managing Schema Objects.
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.
Database structure and space Management
SQL Creating and Managing Tables
Database Tuning - User and Rollback Data Spaces, Recovery, Backup
Oracle 10g Database Administrator: Implementation and Administration
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
SQL Creating and Managing Tables
Database structure and space Management
SQL Creating and Managing Tables
Introduction To Oracle 10g
Object-Relational Features
Managing Indexes.
Managing Tables.
Managing Tablespaces and Data Files
Presentation transcript:

Week 4 Lecture 2 Advanced Table Management

Learning Objectives  Create tables with large object (LOB) columns and tables that are index-organized  Understand the tasks involved in table management  Use data dictionary views to find information about tables and their underlying structures

Advanced Table Structures Table types covered:  Tables with LOB columns:  Store large amount of data in a single column of one row  Can define a separate segment for the LOB  Index-organized tables  Store data in primary key order  Best when queries nearly always use primary key to look up data in the table

Tables with LOB Columns Types of LOB columns: Internal LOB Stored inside the database Datatypes: BLOB, CLOB, NCLOB External LOB Stored outside the database Datatypes: BFILE Read-only

Tables with LOB Columns Example: CREATE TABLE SOUNDBYTES (ALBUM_ID VARCHAR2(20), ARTIST VARCHAR2(40), CD_MUSIC BFILE, POSTER_SHOT BLOB ); External LOB Internal LOB

Tables with LOB Columns New package for updating internal LOBs: DBMS_LOB.LOADBLOBFROMFILE: Load data into BLOB from external file DBMS_LOB.LOADCLOBFROMFILE: Load data into CLOB from external file Co

Tables with LOB Columns Semantics of copying LOBs: Internal LOB uses copy semantics: Copying a LOB from one row or column to another copies the contents External LOB uses reference semantics: Copying a LOB from one row or column to another copies only a pointer to the original location of contents Co

LOB Storage Internal LOBs: Default stored inline or out of line, by size Always stored out of line with DISABLE STORAGE IN ROW External LOBs: LOB locator stored in the table LOB data stored in operating system file

LOB Storage Syntax: CREATE TABLE (, ) LOB ( ) STORE AS (TABLESPACE ENABLE STORAGE IN ROW|DISABLE STORAGE IN ROW CHUNK STORAGE (INITIAL NEXT MAXEXTENTS UNLIMITED| ) PCTVERSION |RETENTION LOGGING|NOLOGGING CACHE|NOCACHE);

LOB Storage Syntax of storage for LOB: STORE AS DISABLE / ENABLE STORAGE IN ROWS CHUNK PCTVERSION / RETENTION LOGGING / NOLOGGING CACHE / NOCACHE

LOB Storage Example:

Index-Organized Tables  Relational table with primary key  Sorted and stored in key order  Normal relational tables are heap- organized  Stored in b-tree structure

Index-Organized Tables Heap-organized versus Index- organized

Index-Organized Tables Example:

Index-Organized Tables Syntax components: ORGANIZATION INDEX OVERFLOW PCTTHRESHOLD INCLUDING TABLESPACE STORAGE ( )

Index-Organized Tables Example: CREATE TABLE ZIPREFERENCES (ZIPCODE VARCHAR2(10) NOT NULL, CITY VARCHAR2(40) NOT NULL, STATE VARCHAR2(10) NOT NULL, PROVINCE VARCHAR2(10) NOT NULL, COUNTRY VARCHAR2(20) NOT NULL, CONSTRAINT ZIP_PK PRIMARY KEY(ZIPCODE)) ORGANIZATION INDEX TABLESPACE USERS PCTTHRESHOLD 20 OVERFLOW TABLESPACE USERS STORAGE (INITIAL 64K NEXT 32K MAXEXTENTS 50 PCTINCREASE 0);

Overview of Table Management Types of changes: Collecting and Refreshing Statistics Change the storage settings Reorganize the table online Drop columns Truncate or drop the table

Analyzing a Table Why analyze tables? To give the optimizer up-to-date information for optimizing queries and other SQL commands To give you information to help you decide which storage or column settings to change

Analyzing a Table Oracle's optimizers: Cost-based optimizer Default Uses table statistics Rule-based optimizer Older Uses syntax rules only

Analyzing a Table Examples ANALYZE command: ANALYZE TABLE CUSTOMER ESTIMATE STATISTICS SAMPLE 1000 ROWS; DBMS_STATS package: EXECUTE DBMS_STATS.GATHER_TABLE_STATS - ('CLASSMATE','CUSTOMER');

Adjusting Table Storage Structure Syntax of ALTER TABLE command: ALTER TABLE. PCTFREE PCTUSED INITTRANS MAXTRANS STORAGE (NEXT PCTINCREASE MAXEXTENTS |UNLIMITED) ALLOCATE EXTENT SIZE DATAFILE DEALLOCATE UNUSED KEEP COMPRESS|NOCOMPRESS MOVE TABLESPACE STORAGE (INITIAL NEXT PCTINCREASE MAXEXTENTS |UNLIMITED) COMPRESS|NOCOMPRESS ONLINE

Adjusting Table Storage Structure Syntax components: PCTFREE PCTUSED INITTRANS MAXTRANS STORAGE (...) ALLOCATE EXTENT DEALLOCATE UNUSED COMPRESS MOVE ONLINE

Adjusting Table Storage Structure Examples: Deallocate unused space: ALTER TABLE HORSERACE DEALLOCATE UNUSED KEEP 50K; Change STORAGE setting: ALTER TABLE CLASSIFIED_AD MOVE TABLESPACE USERS STORAGE (NEXT 56K);

Reorganizing a Table DBMS_REDEFINITION package: Redefine anything in the table Keep old version of the table available during the change

Reorganizing a Table DBMS_REDEFINITION steps: 1. Check the table – is it eligible 2. Create interim table with changes you want done 3. Start redefinition process 4. Finish redefinition process Each step (except #2) is a call to DBMS_REDEFINITION package

Making Other Table Changes Syntax of the ALTER TABLE command: ALTER TABLE. RENAME TO LOGGING|NOLOGGING MONITORING|NOMONITORING ENABLE|DISABLE ROW MOVEMENT CACHE|NOCACHE

Making Other Table Changes Example: Modify monitoring and cache: ALTER TABLE EMPLOYEE MONITORING CACHE;

Dropping, Adding, or Modifying a Column in a Table Syntax for ALTER TABLE command: ALTER TABLE. RENAME COLUMN TO ADD (,... ) MODIFY (,... ) DROP (,,...)|COLUMN CASCADE CONSTRAINTS SET UNUSED (,,...)|COLUMN CASCADE CONSTRAINTS DROP UNUSED COLUMNS Note: Each of these clauses must be used alone in a single ALTER TABLE command.

Dropping, Adding, or Modifying a Column in a Table Examples: Rename a column: ALTER TABLE CH08SURGERY RENAME COLUMN PATIENT_FISRT_NAME TO PATIENT_FIRST_NAME; Add a column: ALTER TABLE CH08SURGERY ADD (OUTCOME VARCHAR2(40), OPERATING_ROOM_NO CHAR(4)); Change length of column: ALTER TABLE CH08SURGERY MODIFY (DOCTOR_NAME VARCHAR2(20));

Truncating and Dropping a Table TRUNCATE is fast: No redo log entries No undo records Cannot rollback Syntax: TRUNCATE TABLE. DROP STORAGE|REUSE STORAGE

Truncating and Dropping a Table DROP command: Removes data and structure Must drop constraints that use the dropped table Example: DROP TABLE COPCAR CASCADE CONSTRAINTS;

Querying Table-Related Data Dictionary Views

Example: Look at statistics gathered by monitoring tables: SELECT TABLE_NAME, TABLESPACE_NAME, MONITORING, BLOCKS, EMPTY_BLOCKS FROM USER_TABLES;

Lecture Summary LOB data types are either internal LOBS or external LOBS New features in the DBMS_LOB package simplify loading LOB data Internal LOB values larger than 4000 bytes are stored out of line in a LOB data segment Oracle9i works with LOBs by reading and writing one chunk at a time LOB data segments can also be used to store varray data

Lecture Summary Index-organized tables require a primary key and store data in order Optionally split the column data into the main segment and an overflow segment The ANALYZE command gathers statistics The DBMS_STATS package also gathers statistics Change a table’s storage parameters using the ALTER TABLE command

Lecture Summary DBMS_REDEFINITION restructures a table while keeping it online ALTER TABLE can do these tasks: Move table to different tablespace Release unused space Rename the table Modify columns (add, change, drop) TRUNCATE removes rows permanently

Lecture Summary TRUNCATE can release unused space or keep the space DROP TABLE removes data and structure CASCADE CONSTRAINTS if the table being dropped is connected by constraints to other tables