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

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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/76065/viewspace-1012310/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值