Download presentation
Presentation is loading. Please wait.
Published byDonald Washington Modified over 9 years ago
1
Harvard University Oracle Database Administration Session 6 Object Storage
2
Harvard University Note The mid-term will be held week 8, March 18 st, just before spring break It will be open book. An understanding of the concepts is most important.
3
Harvard University Note On-line TA session run by Joel Thursday Nights 7:30PM - 9:30PM Using Elluminate Hands-on TA session run by Rohit After class Wednesday night, RM 102, 53 Church St
4
Harvard University Data Storage The units for data storage allocation are extents A table is a segment An index is a segment Segments are sets of extents An extent is a specific number of contiguous data blocks
5
Harvard University Data Storage The data for a table is stored in a data segment The data for an index is stored in an index segment
6
Harvard University Data Storage The extents of a segment may or may not be contiguous on the disk A segment and all of its extents are stored in one tablespace
7
Harvard University Blocks The data block is broken into the following sections – Header contains the block address and type of segment – Table Directory contains information about the table – Row Directory contains the address for each row or row piece – Free space is used to insert new rows or update existing rows – Row Data is the area that currently has data
8
Harvard University Blocks
9
Harvard University PCTFREE PCTFREE – States that a percentage of each data block in a table’s data segment, will be kept free for possible updates, of existing rows, in the future
10
Harvard University PCTUSED PCTUSED – The parameter that sets the minimum percentage of a block, that can be used for row data plus overhead before new rows will be added to the block. After a data block is filled to the limit determined by PCTFREE, Oracle considers the block unavailable for the insertion of new rows until it falls below PCTUSED block falls below the parameter PCTUSED.
11
Harvard University The Table A regular table is the method used to store user data We have very little control in how data is stored in a regular table Rows may be stored in any order, depending on the activity on the table
12
Harvard University Ordinary Tables Ordinary (heap-organized) table General purpose table The data is stored as an unordered collection (heap)
13
Harvard University The Row Row data is stored in database blocks as variable length records The Columns of a row are stored in the order in which they are defined Each row in a table can have a different number of columns
14
Harvard University The Row Each row has a row header It contains the number of columns in the row, the chaining information and the row lock status Each row has row data For each column, Oracle stores the column length and then the value
15
Harvard University The Row Each row in a table having less than 256 columns are stored as one or more row pieces If there are more than 255 columns then the row uses intra-block chaining
16
Harvard University The Row One byte is needed to store the column length if the length cannot exceed 250 bytes Three bytes are needed if the the length is longer The column value is stored immediately after the column length bytes
17
Harvard University The Row Adjacent rows do not need any space between them Each row in the block has a slot in the row directory The directory slot points to the beginning of the row
18
Harvard University Data Types There are a number of scalar data types – Character data – Numeric data – Date data type Character data can be stored in either fixed- length or variable length strings Fixed length such as CHAR is stored with padded blanks
19
Harvard University Data Types Variable-length use only the number of bytes needed to store the actual column value These can vary in size up to 4,000 bytes VARCHAR2 is an example of variable length
20
Harvard University Data Types Numbers are always stored as variable length data It can store up to 38 significant digits
21
Harvard University Data Types Numeric data needs – One byte for the exponent -- Exponents are a shorthand way to show how many times a number, called the base, is multiplied times itself. A number with an exponent is said to be "raised to the power" of that exponent. – One byte for every two significant digits in the mantissa – after the decimal point – One byte for negative numbers if the number of significant digits is less than 38 bytes
22
Harvard University Data Types Dates are stored in fixed-length fields of seven bytes An Oracle DATE always includes time The Raw data type enables the storage of small binary data The number of bytes needed to store the column is variable, up to 2,000 bytes
23
Harvard University Null Values A null is the absence of a value in a column of a row. Nulls indicate missing, unknown, or inapplicable data. A null should not be used to imply any other value, such as zero. A column allows nulls unless a NOT NULL, in which case no row can be inserted without a value for that column. Nulls are stored in the database if they fall between columns with data values. In these cases they require 1 byte to store the length of the column (zero).
24
Harvard University Null Values In tables with many columns, the columns more likely to contain nulls should be defined last to conserve disk space. Comparisons between nulls and other values are by definition neither true nor false, but unknown.
25
Harvard University ROWID The ROWID is a pseudo-column that can be queried along with other columns in a table It has the following characteristics – It is unique identifier for each row in the database – It is not stored as a column value – It does not give the actual physical address of the row, but can be used to locate the row
26
Harvard University ROWID – It is the fastest means of accessing a row in a table – ROWID needs 10 bytes of storage and is displayed using 18 characters
27
Harvard University ROWID The ROWID are made up of the following components – The data object number is assigned to each data object, such as a table or index, when it is created. It is unique within the database – The relative file number is unique to each file within a tablespace – The block number represents the position of the block containing the row within the file – The row number identifies the position of the row directory slot in the block header
28
Harvard University ROWID ROWID is displayed using a base-64 encoding scheme – Data object number 6 positions – Relative file number 3 positions – Block number 6 positions – Row number 3 positions
29
Harvard University ROWID Select ROWID from Example – AAADC4AACAAAAMAAAA – AAADC4 is the data object number – AAC is the relative file number – AAAAMA is the block number – AAA is the row number
30
Harvard University The Storage Clause Storage (initial bytes, next bytes, minextents integer, maxextents integer, pctincrease integer)
31
Harvard University Create Table Create table [schema.] table (column datatype [, column datatype] …) [TABLESPACE tablespace] [pctfree integer] [pctused integer] [initrans integer] [maxtrans integer] [Segment storage clause] [logging | nologging] [cache | nocache]
32
Harvard University Create Table create table [schema].table_name (first_name varchar2(15), ---15 characters middle_initial char(2), ---2 characters last_name varchar2(20)), ---20 characters
33
Harvard University Create Table Schema is the table owner Table_name is the name of the table Column is the name of the column Datatype is the data type of the column Tablespace is the tablespace where the table will be created
34
Harvard University Create Table Logging specifies that the creation of the table will be logged in the redo log file Nologging specifies that the creation of the table and certain types of data loads will not be logged in the redo log file
35
Harvard University Create Table Cache specifies that the blocks retrieved for this table are in the most recently used end of the LRU list, in the buffer cache Nocache specifies that the blocks retrieved for this table are in the least recently used end of the LRU list, in the buffer cache
36
Harvard University Create Table Create tables in a separate tablespace, one that does not have indexes, rollback segments or temporary segments Use a few standard extent sizes that are multiples of 5 * db_block_size, to minimize fragmentation example 5 * 8k = 40k * 100 = 4M 5 * 16k = 80k * 100 = 8M
37
Harvard University Create Table It is easier to use the autoallocate clause, when creating the locally managed tablespace Use the cache clause for small reference tables that are accessed frequently
38
Harvard University Alter Table To change an existing table we use the ALTER TABLE command Alter table [schema.] table {[storage-clause] [pctfree integer] [Pctused integer] [Initrans integer] [maxtrans integer]
39
Harvard University Alter Table The changes in the storage take effect on any new extents that are allocated The value of INITIAL extent cannot be modified The value of the NEXT extent is rounded to a multiple of the block size greater to or equal to the value specified
40
Harvard University Alter Table Changes to the block parameters PCTFREE and INITRANS will effect only new blocks Changes to PCTUSED and MAXTRANS will effect all blocks Block Parameters are changed to improve space utilization and reduce migration
41
Harvard University Row Chaining Row chaining occurs when a row is too large to fit into a single block The row is too large to fit into one data block upon first insertion it is first inserted It is then divided into row pieces Each row piece is stored in different blocks The necessary pointers to retrieve the whole row are provided
42
Harvard University Migration When a row that originally fit into one data block, is updated, so that the overall row length increases, and the block’s free space is already completely filled. Oracle migrates the data for the entire row to a new data block, assuming the entire row can fit in a new block. The rowid of a migrated row does not change.
43
Harvard University Migration When a row is chained or migrated, I/O performance associated with this row decreases Oracle now must scan more than one data block to retrieve the information for the row. Row Chaining can be minimized by choosing a larger block size or splitting the table into multiple tables, with fewer columns
44
Harvard University Views A view is not allocated any storage space A view does not contain data A view is defined by a query that extracts or derives data from the tables that the view references. These tables are called base tables.
45
Harvard University Materialized Views Materialized views are schema objects that can be used to summarize, compute, replicate, and distribute data. Data is stored as if they were tables
46
Harvard University Locally Managed Tablespaces The CREATE TABLESPACE command has an "extent_management_clause", that specifies how the extents of the tablespace will be managed. This clause uses one of the following parameters: - DICTIONARY: Specifies that the tablespace is managed using dictionary tables. This is the default for 8i. - LOCAL: Specifies that the tablespace is locally managed. Locally managed tablespaces have some part of the tablespace set aside for a bitmap.
47
Harvard University Locally Managed Tablespaces The storage parameters NEXT, PCTINCREASE, MINEXTENTS, MAXEXTENTS, and DEFAULT STORAGE are not valid for extents that are managed locally.
48
Harvard University Automatic Segment Space Management (ASSM) CREATE TABLESPACE USERS DATAFILE '/u04/app/oracle/product/9.0.1/oradata/ /t est.dbf' SIZE 1M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K SEGMENT SPACE MANAGEMENT AUTO;
49
Harvard University Automatic Segment Space Management (ASSM The tablespace must be permanent and locally managed. If used, the segment ignores PCTUSED and FREELIST
50
Harvard University Reading Oracle11g Concepts Guide – Part 2 Oracle Database Architecture Chap 2 and 3 Chap 5 thru 8 Chap 12
51
Harvard University Reading Oracle11 Administration Guide – Part 1 Basic Database Administration Chap 1 thru 6 – Part 2 Oracle Database Structure and Storage Chap 9 thru 14
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.