ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Use the following approach to create tables with constraints and indexes:

Use the following approach to create tables with constraints and indexes:

原创 Linux操作系统 作者:foreverlee 时间:2008-10-23 16:48:21 0 删除 编辑

Use the following approach to create tables with constraints and indexes:

[@more@]

1.

should be created enabled and validated. All other constraints (

Create the tables with the constraints. NOT NULL constraints can be unnamed andCHECK, UNIQUE,

PRIMARY KEY

, and FOREIGN KEY) should be named and created disabled.

See Also:

information about the

Oracle Database SQL Language Reference for moreCREATE INDEX and ALTER INDEX

statements, as well as restrictions on rebuilding indexes

See Also:

Database Administrator's Guide

syntax for this statement

Oracle Database SQL Language Reference and Oraclefor more information about the

Using Function-based Indexes for Performance

Using Indexes and Clusters

2.

15-7Load old data into the tables.

3.

Create all indexes, including indexes needed for constraints.

4.

Enable novalidate all constraints. Do this to primary keys before foreign keys.

5.

Allow users to query and modify data.

6.

constraints. Do this to primary keys before foreign keys. For example,

With a separate ALTER TABLE statement for each constraint, validate all

CREATE TABLE t (a NUMBER CONSTRAINT apk PRIMARY KEY DISABLE,

b NUMBER NOT NULL);

CREATE TABLE x (c NUMBER CONSTRAINT afk REFERENCES t DISABLE);

Now you can use Import or Fast Loader to load data into table

t.

CREATE UNIQUE INDEX tai ON t (a);

CREATE INDEX tci ON x (c);

ALTER TABLE t MODIFY CONSTRAINT apk ENABLE NOVALIDATE;

ALTER TABLE x MODIFY CONSTRAINT afk ENABLE NOVALIDATE;

At this point, users can start performing

on table

INSERTs, UPDATEs, DELETEs, and SELECTst.

ALTER TABLE t ENABLE CONSTRAINT apk;

ALTER TABLE x ENABLE CONSTRAINT afk;

Now the constraints are enabled and validated.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/76065/viewspace-1012310/,如需转载,请注明出处,否则将追究法律责任。

下一篇: Partition Pruning
请登录后发表评论 登录
全部评论

注册时间:2008-11-26

  • 博文量
    72
  • 访问量
    1356448