Segments Part I
All the above segment types are the logical structures next to tablespaces within Oracle Database and are associated with a tablespace and can not live independently. A DBA plans/ designs tablespaces of different types basing on the nature of the contents of the segment. CACHE Meatalink ID number 107709.1 explains what is CACHE segment and what are DO NOTs for you and me. When the database is created, a segment of type 'CACHE' is created. It is owned by 'SYS' and resides in the system tablespace. It can been found by querying DBA_SEGMENTS or USER_SEGMENTS for a segment_type of 'CACHE' and has one extent allocated but MAX_EXTENTS = 0. The name of the segment will be 1.<number> which is derived from the values of HEADER_FILE.HEADER_BLOCK in DBA_SEGMENTS. This file and block marks the beginning of non-bootstrap data dictionary objects. All objects which are created prior to bootstrap$ in SQL.BSQ are required for warm starting the instance. These objects can only be created from CREATE DATABASE. The CACHE object SYS.1.<header_block_number> marks the starting block where non-bootstrap objects will reside. For example, SYS.1.527, segment_type='CACHE' is located in HEADER_FILE 1, HEADER_BLOCK 527 The data dictionary elements created prior to bootstrap$ are absolutely necessary for database operations since all other objects are built from them (fet$, uet$, obj$, tab$, c_ts#, etc...). The database will not open if these objects do not exist or are corrupted (ORA-704). It is an unsupported action to modify data dictionary objects.
Because clusters store related rows of different tables together in the same data blocks, properly used clusters offer two primary benefits: Disk I/O is reduced and access time improves for joins of clustered tables. The cluster key is the column, or group of columns, that the clustered tables have in common. You specify the columns of the cluster key when creating the cluster. You subsequently specify the same columns when creating every table added to the cluster. Each cluster key value is stored only once each in the cluster and the cluster index, no matter how many rows of different tables contain the value. Therefore, less storage might be required to store related table and index data in a cluster than is necessary in non-clustered table format. How
to create CLUSTERS?
To create a table in a cluster, you must have either the CREATE TABLE or CREATE ANY TABLE system privilege. You do not need a tablespace quota or the UNLIMITED TABLESPACE system privilege to create a table in a cluster. You create a table in a cluster using the CREATE TABLE statement with the CLUSTER option. The emp and dept tables can be created in the emp_dept cluster using the following statements: CREATE
TABLE emp ( CREATE
TABLE dept ( You can specify the schema for a clustered table in the CREATE TABLE statement. A clustered table can be in a different schema than the schema containing the cluster. Also, the names of the columns are not required to match, but their structure must match.
CREATE
INDEX emp_dept_indexON CLUSTER emp_dept The cluster index clause (ON CLUSTER) identifies the cluster, emp_dept, for which the cluster index is being created. The statement also explicitly specifies several storage settings for the cluster and cluster index. To alter a cluster, your schema must contain the cluster or you must have the ALTER ANY CLUSTER system privilege. You can alter an existing cluster to change the following settings: Physical
attributes (PCTFREE, PCTUSED, INITRANS, MAXTRANS, and storage characteristics)
When you alter data block space usage parameters (PCTFREE and PCTUSED) or the cluster size parameter (SIZE) of a cluster, the new settings apply to all data blocks used by the cluster, including blocks already allocated and blocks subsequently allocated for the cluster. Blocks already allocated for the table are reorganized when necessary (not immediately). When you alter the transaction entry settings (INITRANS and MAXTRANS) of a cluster, a new setting for INITRANS applies only to data blocks subsequently allocated for the cluster, while a new setting for MAXTRANS applies to all blocks (already and subsequently allocated blocks) of a cluster. The storage parameters INITIAL and MINEXTENTS cannot be altered. All new settings for the other storage parameters affect only extents subsequently allocated for the cluster. To alter a cluster, use the ALTER CLUSTER statement. The following statement alters the emp_dept cluster:
|