Previous | Table of Contents | Next |
The basic unit of information storage within an Oracle database is a table. A table contains rows of data which represent instances of a given entity (for example, addresses for employees). The table also has columns which represent attributes associated with the rows (for example, the city and state for a given address). Oracle has expanded its column capabilities over the years to progress from simple number and character data storage to more complex data types such as video, audio, or image data.
You might be interested in knowing how Oracle chooses which bytes on the disk to use to store the file and how it delimits the various columns and other such detailed storage data, but its not necessary. When you insert a row into a table, Oracle finds the correct spot within the extents that you have allocated for that table and stores the data in a manner that you can retrieve it. Oracle keeps track of the exact location of the bits and bytes. The only internal storage feature that you might use is the row ID. This unique number specifies a given row in a given table. That way, if you have multiple rows in a table that have the exact same values and you want to get rid of one of them, you can use the row ID to do it.
Here is a sample command used to create a table called golf_scores:
create table golf_scores (course char(20), date_played date, partner char(20), front_nine number(3), back_nine number(3), total number(3)) initrans 1 maxtrans 100 tablespace user_data storage ( initial 10K next 10K pctincrease 0 minextents 1 maxextents 100);
The most straightforward approach to analyzing this command (and tables in general) is to break down the command into its components:
Each column in a table has a column name, a datatype, and some sizing parameters. The rules for column names are the same as the rules for table names, and its a good idea to use column names that are meaningful. Character data has a size to it that specifies the maximum length of the character string. Numbers have precision and scale. Precision refers to the total number of digits, not including the exponent when this number is expressed in exponential notation. The scale specifies the number of digits to the right of the decimal place. A number with a precision of 5 and a scale of 2 will range between 999.99 and +999.99 and is considered to be datatype number(5,2). Table 12.1 lists datatypes supported by Oracle (older versions may not support the long raw or varchar2 datatypes):
Datatype | Meaning | Fixed/Variable Length |
---|---|---|
char(size) | Character | Fixed length (trailing spaces added) |
varchar2(size) | Character | Variable length (uses what is needed) |
number(prec,scale) | Number | Variable length (uses what is needed) |
date | Date and time | Seven bytes per column (year 2000 compliant) |
long | Character | Variable length up to 64KB in Oracle6 or 2GB per row in Oracle7 |
raw(size) | Free-form | Variable length up to 2,000 bytes per row |
long raw | Free-form | Variable length up to 64KB in Oracle6 or 2GB per row in Oracle7 |
rowid | Binary | Six bytes per row that can be represented as a number in queries |
Previous | Table of Contents | Next |