首页 > Linux操作系统 > Linux操作系统 > 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 INDEXstatements, 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 theUsing 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 allCREATE 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博客 ” ,链接:https://blog.itpub.net/76065/viewspace-1012310/ ,如需转载,请注明出处,否则将追究法律责任。