Oracle Tips by Burleson Consulting
have discussed several times, a table is a structure that holds rows
(or records) of data. A table is composed of columns, each column
has a data type and each column can hold some amount of data of that
in EnterpriseDB are stored as files in the file system. A single
table is a single file.
TABLESPACES and SCHEMAs
spoke of tablespaces and schemas in Chapter 2, The EnterpriseDB
Platform. A tablespace is a pointer to a directory and a schema is
a grouping of database objects. A tablespace or schema in
EnterpriseDB is conceptually similar to the same in Oracle but is
implemented quite a bit differently. I will show an example using
tablespaces and schemas below but if you don't quite understand that
use, don't worry about it at this point. If you ever do need the
functionality they provide, the use will become obvious.
Default column expression allows you to force a value in a table if
the value is not provided in an insert statement.
may set a column as NULL or NOT NULL. A NOT NULL column will not
allow the column to have no value. Many times, a DEFAULT is used
with a NOT NULL to ensure a value. A NULL means that the column can
be empty. NULL is the default.
UNIQUE keyword identifies a unique constraint. A unique constraint
forces the column (or a combination of columns) to be unique for all
records in the table.
Unique constraint may be declared at the table level or at the
column level. At the column level, the unique constraint may
reference only that single column. At the table level, a unique
constraint may reference multiple columns.
Primary Key constraint is much like a unique constraint. The
differences are that a PRIMARY KEY (a single column or combination
of columns) must be NOT NULL and Unique. You may define only a
single Primary Key for any particular table.
Primary Key constraint creates a Unique Index on the column(s) you
Check constraint allows you to validate data without writing code.
If you want to ensure that a column can only contain a certain
selection of data, a check constraint is the best way to do it. A
check constraint must evaluate to a boolean value, i.e. 1 = 1 or 1 =
2. The first would evaluate to TRUE (1 equals 1) and the second
would evaluate to false (1 equals 2). 1 + 1 would not be a valid
check constraint because it does not evaluate to TRUE or FALSE.
constraint keyword allows you to name a constraint. You may use
CONSTRAINT with a Unique, Primary Key, NULL|NOT NULL, or Check
constraint to name it. If you do not provide a name, the database
will generate a name for you.
reference is a foreign key constraint. You would use a reference to
relate a child table to its parent table. In our example earlier,
the EMP table is a child of DEPT. There is a reference between
and DEPT.deptno. A table level foreign key reference on EMP would
look like: FOREIGN KEY (deptno)
REFERENCES dept (deptno).
is an excerpt from the book "EnterpriseDB:
The Definitive Reference" by Rampant TechPress.