Oracle Schema Objects——Tables——Overview of Tables

Oracle Schema Objects

Overview of Tables

 

A table is the basic unit of data organization in an Oracle database.

Oracle数据库中的数据组织基本单位

 

A table describes an entity, which is something of significance about which information must be recorded.

一个表描述了一个实体,其相关重要信息必须被记录。

 

A table is either permanent or temporary.

表要么是永久的,要么是临时的。

 

Relational tables

关系表

Relational tables have simple columns and are the most common table type.

关系表具有简单的列,是最常见的表类型。

可以创建如下关系表:

堆组织表

heap-organized table

A heap-organized table does not store rows in any particular order. The CREATE TABLE statement creates a heap-organized table by default.

它不会以任何特定顺序存储行

索引组织表

index-organized table

An index-organized table orders rows according to the primary key values. For some applications, index-organized tables enhance performance and use disk space more efficiently.

它按主键值对行进行排序。 对于某些应用程序,索引组织表可以增强性能并更有效地使用的磁盘空间

外部表

external table

An external table is a read-only table whose metadata is stored in the database but whose data in stored outside the database.是一个只读表,它的元数据存储在数据库中,但其数据存储在数据库外

Object tables

对象表

The columns correspond to the top-level attributes of an object type.

列对应于对象类型的顶层属性。

 

Columns and Rows

行和列

A table definition includes a table name and set of columns.

表的定义包括表名称列集

 

1A column identifies an attribute of the entity described by the table.

列标识由表所描述的实体的一个属性

 

virtual column

虚拟列

  • A table can contain a virtual column, which unlike a nonvirtual column does not consume disk space.

表可以包含虚拟的列,与非虚拟列不一样,虚拟列不占用磁盘空间

  • The database derives the values in a virtual column on demand by computing a set of user-specified expressions or functions.

数据库通过计算一组用户指定的表达式或函数,按需派生出虚拟的列值

  • For example, the virtual column income could be a function of the salary and commission_pct columns.

例如虚拟列 income 可能是 salary 列和 commission_pct 列的一个函数

 

2 A row is a collection of column information corresponding to a record in a table.

行是对应于表中某条记录的列信息的集合

 

create a table

创建表

1In general, you give each column a column name, a data type, and a width when you create a table.

一般地,当创建一个表时,给每列一个列名称、数据类型、宽度

 

2CREATE TABLE Statements

CREATE TABLE employees
    ( employee_id    NUMBER(6)
    , first_name     VARCHAR2(20)
    , last_name      VARCHAR2(25)
         CONSTRAINT     emp_last_name_nn NOT NULL
    , email          VARCHAR2(25)
        CONSTRAINT     emp_email_nn NOT NULL
    , phone_number   VARCHAR2(20)
    , hire_date      DATE
        CONSTRAINT     emp_hire_date_nn NOT NULL
    , job_id         VARCHAR2(10)
        CONSTRAINT     emp_job_nn NOT NULL
    , salary         NUMBER(8,2)
    , commission_pct NUMBER(2,2)
    , manager_id     NUMBER(6)
    , department_id NUMBER(4)
    , CONSTRAINT     emp_salary_min
                     CHECK (salary > 0)
    , CONSTRAINT     emp_email_uk
                     UNIQUE (email)
    ) ;

 

 

3ALTER TABLE Statements

ALTER TABLE employees
ADD ( CONSTRAINT     emp_emp_id_pk
                       PRIMARY KEY (employee_id)
    , CONSTRAINT     emp_dept_fk
                       FOREIGN KEY (department_id)
                         REFERENCES departments
    , CONSTRAINT     emp_job_fk
                       FOREIGN KEY (job_id)
                         REFERENCES jobs (job_id)
    , CONSTRAINT     emp_manager_fk
                       FOREIGN KEY (manager_id)
                         REFERENCES employees
    ) ;

 

posted @ 2017-06-22 11:45  寻香径  阅读(322)  评论(0编辑  收藏  举报