Nonstop Database, HiRDB Version 9 Description

[Contents][Glossary][Index][Back][Next]

3.3.1 Basic table structure

Organization of this subsection
(1) Rows and columns
(2) Data types

(1) Rows and columns

The cells in a table's horizontal plane constitute rows; the cells in the vertical plane constitute columns. The row is the unit for performing operations on a table. Each row consists of data entries from one or more columns. Each column is given a column name. When an operation is performed on a table, you identify the position of an item in a row by its column name. The following figure shows the structure of a table.

Figure 3-4 Example of a table

[Figure]

Explanation
This example illustrates the structure of an inventory table (the table name is STOCK). The columns are defined with the CREATE TABLE in the definition SQL. Following is the definition of the STOCK table's columns:
 
CREATE TABLE STOCK
   (PCODE CHAR(4),
    PNAME NCHAR(8),
    COLOR NCHAR(1)
    PRICE INTEGER,
    SQUANTITY INTEGER);

(2) Data types

A data type must be specified for each column and for each attribute comprising an abstract data type. Data types are classified broadly as predefined data types and user-defined data types. A predefined data type is provided by HiRDB. A user-defined data type is defined by a user as needed. The following table lists the available data types.

Table 3-3 Available data types

Classification Data type Data format
Predefined Numeric data INTEGER Integer
SMALLINT Integer
LARGE DECIMAL Fixed point
FLOAT Double-precision floating point
SMALLFLT Single-precision floating point
Character data CHARACTER Fixed-size character string
VARCHAR Variable-size character string
National character data NCHAR Fixed-size national character string
NVARCHAR Variable-size national character string
Mixed character data MCHAR Fixed-size mixed character string
MVARCHAR Variable-size mixed character string
Date data DATE Date
Time data TIME Time
Time-stamp data TIMESTAMP Precision for time-stamp data in floating-point seconds
Date interval data INTERVAL YEAR TO DAY Date interval
Time interval data INTERVAL HOUR TO SECOND Time interval
Large object data BLOB Binary data string
Binary data BINARY Binary data string
Boolean data BOOLEAN Boolean value
User-defined Abstract data type -- --

--: Not applicable

Data types are specified when a table is created with the CREATE TABLE of the definition SQL. The data type for an attribute comprising an abstract data type is specified with the CREATE TYPE of the definition SQL. For details about abstract data types, see Section 3.5 Expansion into an object relational database.