Presentation is loading. Please wait.

Presentation is loading. Please wait.

Managing Tables.

Similar presentations


Presentation on theme: "Managing Tables."— Presentation transcript:

1 Managing Tables

2 Objectives Distinguishing between different Oracle data types
Creating tables using appropriate storage settings Controlling the space used by tables Analyzing tables to check integrity and migration Retrieving information about tables from the data dictionary Converting between different formats of ROWID Lesson Aim <Enter lesson aim here.>

3 Index-organized table
Storing User Data Regular table Partitioned table Cluster Index-organized table

4 Structure of a Row Database block Row header Column length
Column value

5 Oracle Data Types Data type User-defined Built-in Scalar Collection
Relationship CHAR(N), NCHAR(N) VARCHAR2(N), NVARCHAR2(N) NUMBER(P,S) DATE RAW(N) BLOB, CLOB, NCLOB, BFILE LONG, LONG RAW ROWID VARRAY TABLE REF

6 ROWID Data Type Unique identifier for a row Used to locate a row
ROWID Format OOOOOO FFF BBBBBB RRR Data object number Relative file number Block number Row number

7 Collections Collections are objects that contain objects.
VARRAYs are ordered sets of elements containing a count and a limit. Nested tables are tables with a column or variable of the TABLE data type. Nested table VARRAY Describing Collections A collection is an object that contains other objects, where each contained object is of the same type. Collection types are parameterized datatypes. Collection types are arrays (VARRAY datatype) and nested tables. VARRAYs can be used to hold lists of objects, REFs, or scalar datatypes. They are primarily useful in dealing with small sets, where individual elements need not be manipulated through SQL. Nested tables are used where large sets of data need to be placed within a parent table and are typically useful there is a master-detail relationship, where for a given master row, there could be many detailed rows. Collections are discussed in detail in Lesson 7, “Implementing Collection Types.”

8 Creating a Table CREATE TABLE employees( empno NUMBER(4),
last_name VARCHAR2(30) deptno NUMBER(2)) PCTFREE 20 PCTUSED 50 STORAGE(INITIAL 200K NEXT 200K PCTINCREASE 0 MAXEXTENTS 50) TABLESPACE data01;

9 Creating a Table: Guidelines
Use a few standard extent sizes for tables to reduce tablespace fragmentation. Use the CACHE clause for frequently used, small tables.

10 Setting PCTFREE and PCTUSED
Compute PCTFREE (Average Row Size - Initial Row Size) * 100 Average Row Size Compute PCTUSED Average Row Size * PCTFREE Available Data Space

11 Row Migration and Chaining
Before update After update

12 Copying an Existing Table
CREATE TABLE new_emp STORAGE(INITIAL 200K NEXT 200K PCTINCREASE 0 MAXEXTENTS 50) NOLOGGING TABLESPACE data01 AS SELECT * FROM scott.employees;

13 Dropping Tables DROP TABLE scott.departments CASCADE CONSTRAINTS;


Download ppt "Managing Tables."

Similar presentations


Ads by Google