70
module11-tables_clusters.htm; updated June 25, 2013; Some figures shown in these notes are from Oracle document D11321GC11. Ref: Oracle® Database Administrator's Guide 11g Release 2 (11.2) E25494-03 Module 11 – Tables and Clusters Objectives This lesson focuses on the creation and modification of tables as the primary object used to store database information. Learn the Oracle data types. Learn the structure of rows in tables, and the management of storage structures in a table. Reorganize, truncate and drop tables including dropping table columns. Create tables with constraints. Create clusters. A separate set of notes covers index creation applicable to tables. Introduction Tables are the most basic data storage object in Oracle. Data are stored in rows and columns. Each column has a name and data type. Width is specified, e.g, VARCHAR2(25), or precision and scale, e.g., NUMBER(7,2) or may be predetermined as with the DATE data type. Columns may have defined integrity constraints Virtual columns may be defined - derived from an expression.

Module 11

Embed Size (px)

DESCRIPTION

m

Citation preview

module11-tables_clusters.htm; updatedJune 25, 2013; Some figures shon in these notes are from !racle document "11321#$11.%ef&!racle' "atabase (dministrator)s #uide 11g %elease 2 *11.2+ ,25-.--03 Module 11 Tables and Clusters Objectives /his lesson focuses on the creation and modification of tables as the primar0 ob1ect used to store database information. 2earn the !racle data t0pes.2earn the structure of ros in tables, and the management of storagestructures in a table. %eorgani3e, truncate and drop tables including dropping table columns.$reate tables ith constraints. $reate clusters. ( separate set of notes co4ers inde5 creation applicable to tables. Introduction /ables are the most basic data storage ob1ect in !racle."ata are stored inros and columns. ,ach column has a name and data t0pe.6idth is specified, e.g, VARCHAR2(25), or precision and scale, e.g., !M"#R($%2) or ma0 be predetermined as ith the &AT# data t0pe.$olumns ma0 ha4e defined integrit0 constraintsVirtual colu'ns ma0 be defined - deri4ed from an e5pression."ata encr0ption can be transparent. /here are four t0pes of tables used to store data in an !racle database. Tables((lso called a re)ular table or ordinar* table, this is the de+ault table t0pe and the primar0 focus of this instructional module.%os are stored to tables of this t0pe in an0 order so this is also referred to as a ,ea- structure, hich is an unordered collection of data ros.( table has a single segment. .artitioned Tables(/his table t0pe is used to build scalable applications.( partitioned table has one or more partitions.,ach partition stores ros that are partitioned b0 either range, hash, composite, or list partitioning.,ach partition is a separate segment, sometimes in different tablespaces *thus the scalable application+. Inde/0Or)ani1ed Tables (IOT)( /he 7!/ structure is a 4ariant of a 8-tree structure. "ata is stored in an inde5-organi3ed table in a 8-tree inde5 structure in primar0 9e0 sorted order. 7nstead of maintaining a table in one storage location and the primar09e0 inde5 in another location, each entr0 in the 8-tree also stores non-9e0 column 4alues as ell, so the nodes in the tree can become :uite large. (n o4erflo segment ma0 e5ist for the storage of longer ro lengths./hese tables pro4ide fast 9e0-based access for :ueries in4ol4ing e5act matches and range searches.Storage re:uirements are reduced as the primar0 9e0 is onl0 stored in the table, not duplicated in a separate inde5. Clustered Tables(/his table t0pe is comprised of a single or group of tables that share the same data bloc9, thus an indi4idual data bloc9 can ha4e ros stored in it from more than one table. /he tables must share a common column*s+that stores a common domain of 4alues called the cluster 2e*.$lustering is transparent to the applications that :uer0 and manipulate the data for the clustered tables./he cluster 9e0 does not ha4e to be the same as the primar0 9e0 ; it ma0 be the same or a different column set.$lusters are created to impro4e performance.%andom access to indi4idual record sets in a cluster is faster, but table scans are sloer. &ata T*-es ("uilt0In) !racle uses se4eral built-in datat0pes to store scalar data, collections, and relationships./hese data t0pes 4ar0 a bit from the (