You have now completed a whirlwind tour of how to create tables and constraints.
In this module, you practiced creating a table with several columns and saw how to set the space parameters for a table
and watched what happens when a table outgrows its initial allocation of space. You observed what happens when you drop a table. You also saw how to disable a constraint and when you need to do that.
In this module, you learned how to:
- Identify the components of the
CREATE TABLE
command
- Describe how tables, tablespaces, and datafiles fit together
- Identify the parameters that define storage space
- Describe the advantages of using
PRIMARY KEY
constraints
- Identify the syntax components of the
FOREIGN KEY
, CHECK
, and UNIQUE
constraints
- Change columns in an existing table
- Describe the effects of dropping a table and disabling or removing a constraint
In Oracle, you can use the CREATE TABLE statement to set the space parameters for a table. You can specify the storage clause with the following options:
- INITIAL: Specifies the initial amount of space allocated for the table.
- NEXT: Specifies the amount of space allocated for each extent.
- MINEXTENTS: Specifies the minimum number of extents allocated for the table.
- MAXEXTENTS: Specifies the maximum number of extents allocated for the table.
- PCTINCREASE: Specifies the percentage increase in space allocated for each extent.
- FREELISTS: Specifies the number of free lists for the table.
- FREELIST GROUPS: Specifies the number of free list groups for the table.
Here is an example of how to create a table with space parameters:
CREATE TABLE mytable (
id INT,
name VARCHAR2(50),
age INT
)
STORAGE (
INITIAL 100K,
NEXT 50K,
MINEXTENTS 2,
MAXEXTENTS 20,
PCTINCREASE 0,
FREELISTS 1,
FREELIST GROUPS 1
);
Please keep in mind that some of the above options may be deprecated and you should check the Oracle documentation for the most recent information.