Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

157

积分

0

好友

14

主题
1#
发表于 2014-3-26 10:45:26 | 查看: 5464| 回复: 12
<<Oracle 11gR2 SQL Language Reference>>

  1. DISABLE VALIDATE  disables the constraint and drops the index on the constraint,
  2. but keeps the constraint valid. This feature is most useful in data warehousing
  3. situations, because it lets you load large  amounts of data while also saving space
  4. by not having an index. This  setting lets you load data from a nonpartitioned table
  5. into a partitioned table using the  exchange_partition_subpart  clause of the
  6. ALTER TABLE statement or using SQL*Loader. All other modifications to the table
  7. (inserts, updates, and deletes) by other SQL statements are disallowed.
复制代码
如何实现文中所述的“使用SQL*Loader往具有DISABLE VALIDATE约束的表中加载数据”
2#
发表于 2014-3-28 11:33:34
努力召唤各路高手关注

回复 只看该作者 道具 举报

3#
发表于 2014-3-28 13:52:40
请具体给出原文地址

回复 只看该作者 道具 举报

4#
发表于 2014-3-28 16:14:14
<<Online Document>>
http://docs.oracle.com/cd/E11882_01/server.112/e41084/clauses002.htm#i1002349
<<PDF>>
Oracle® Database SQL Language Reference  11g Release 2 (11.2)  E41084-02 July 2013
8 Common SQL DDL Clauses -> constraint -> DISABLE Clause -> DISABLE VALIDATE
Page 8-16 (622页/1636)

回复 只看该作者 道具 举报

5#
发表于 2014-3-28 16:25:18
如何实现文中所述的“使用SQL*Loader往具有DISABLE VALIDATE约束的表中加载数据”


==> 这个我没有明白, 往一个具有DISABLE VALIDATE约束的表使用SQL*LOADER加载数据,在我看来就是普通的SQL*LOADER使用

回复 只看该作者 道具 举报

6#
发表于 2014-3-28 16:28:45
This  setting lets you load data from a nonpartitioned table
into a partitioned table using the  exchange_partition_subpart  clause of the
ALTER TABLE statement or using SQL*Loader
这句话该怎么解读呢?SQL*Loader与设置约束DISABLE VALIDATE是什么关系?

回复 只看该作者 道具 举报

7#
发表于 2014-3-28 16:34:47
Liu Maclean(刘相兵 发表于 2014-3-28 16:25
如何实现文中所述的“使用SQL*Loader往具有DISABLE VALIDATE约束的表中加载数据”

执行SQL*Loader会导致ORA-25128错误

回复 只看该作者 道具 举报

8#
发表于 2014-3-28 16:55:13
数据库 11.2.0.2.0 Linux x86-64
操作系统  RHEL 5.5 x86-64
实验步骤

  1. [oracle@ora11202 ~]$ sqlplus system/oracle@192.168.2.21/orcl

  2. SQL*Plus: Release 11.2.0.2.0 Production on Fri Mar 28 16:49:25 2014

  3. Copyright (c) 1982, 2010, Oracle.  All rights reserved.

  4. Connected to:
  5. Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
  6. With the Partitioning, OLAP, Data Mining and Real Application Testing options

  7. SQL> create tablespace tbs_nby datafile '/u01/oradata/orcl/tbs_nby.dbf' size 8M autoextend on next 8M maxsize 1024M;

  8. Tablespace created.

  9. SQL> create user nby identified by nby default tablespace tbs_nby;

  10. User created.

  11. SQL> grant create session,resource,unlimited tablespace to nby;

  12. Grant succeeded.

  13. SQL> conn nby/nby
  14. Connected.
  15. SQL> CREATE TABLE nby.t_part(ID number,Name varchar2(10),CONSTRAINT pk_part PRIMARY KEY(ID))
  16.   2  partition by range(id)(
  17.   3  partition p1 values less than ('11'),
  18.   4  partition p2 values less than ('21'),
  19.   5  partition p3 values less than ('31'));

  20. Table created.

  21. SQL> INSERT INTO t_part VALUES(1,'aaa');

  22. 1 row created.

  23. SQL> INSERT INTO t_part VALUES(2,'aaa');

  24. 1 row created.

  25. SQL> INSERT INTO t_part VALUES(3,'aaa');

  26. 1 row created.

  27. SQL> INSERT INTO t_part VALUES(4,'aaa');

  28. 1 row created.

  29. SQL> COMMIT;

  30. Commit complete.

  31. SQL> ALTER TABLE t_part MODIFY CONSTRAINT pk_part DISABLE VALIDATE;

  32. Table altered.

  33. SQL> quit
  34. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
  35. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  36. [oracle@ora11202 ~]$ cat test.dat
  37. 11,nby
  38. 12,nby
  39. 13,nby
  40. 14,nby
  41. [oracle@ora11202 ~]$ cat test.ctl
  42. Load DATA
  43. INFILE 'test.dat'
  44. BADFILE 'test.bad'
  45. APPEND
  46. INTO TABLE T_PART
  47. FIELDS TERMINATED BY ","
  48. (ID ,Name)
  49. [oracle@ora11202 ~]$ sqlldr nby/nby@192.168.2.21/orcl control=test.ctl

  50. SQL*Loader: Release 11.2.0.2.0 - Production on Fri Mar 28 16:52:08 2014

  51. Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

  52. SQL*Loader-643: error executing INSERT statement for table T_PART
  53. ORA-25128: No insert/update/delete on table with constraint (NBY.PK_PART) disabled and validated
  54. SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
  55. [oracle@ora11202 ~]$
  56. [oracle@ora11202 ~]$ sqlldr nby/nby@192.168.2.21/orcl control=test.ctl direct=true

  57. SQL*Loader: Release 11.2.0.2.0 - Production on Fri Mar 28 16:52:12 2014

  58. Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

  59. SQL*Loader-951: Error calling once/load initialization
  60. ORA-02373: Error parsing insert statement for table NBY.T_PART.
  61. ORA-25128: No insert/update/delete on table with constraint (NBY.PK_PART) disabled and validated
复制代码

回复 只看该作者 道具 举报

9#
发表于 2014-3-28 17:03:12
more info :
[oracle@mlab2 parnassus_dbinfo_DB_20140328044616]$ sqlldr control=sys.tv.ctl direct=y skip_index_maintenance=true
Username:/ as sysdba

SQL*Loader: Release 11.2.0.3.0 - Production on Fri Mar 28 04:49:57 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

SQL*Loader-951: Error calling once/load initialization
ORA-02373: Error parsing insert statement for table SYS.TV.
ORA-25128: No insert/update/delete on table with constraint (SYS.SYS_C0012793) disabled and validated

回复 只看该作者 道具 举报

10#
发表于 2014-3-28 17:07:35
need to diag more info

回复 只看该作者 道具 举报

11#
发表于 2014-3-28 19:21:12
文中提到的exchange partition并不难理解实现起来也简单。但实在想不出使用sql*loader加载数据后,DBMS拿什么保证数据的唯一性来对得起VALIDATE一词。DISABLE VALIDATE会导致对应索引删除,索引都没有了拿什么来实施约束。

回复 只看该作者 道具 举报

12#
发表于 2014-4-2 14:10:42
求高手们关注

回复 只看该作者 道具 举报

13#
发表于 2014-5-8 16:33:56
唉,沉底了
这个实验来其实自于一道1z0-052的试题,题目如下
Examine the following statement that is used to modify the constraint on the SALES table:
SQL> ALTER TABLE SALES MODIFY CONSTRAINT pk DISABLE VALIDATE;
Which three statements are true regarding the above command? (Choose three.)
A.The constraint remains valid.
B.The index on the constraint is dropped.
C.It allows the loading of data into the table using SQL *Loader.
D.New data conforms to the constraint, but existing data is not checked.
E.It allows the data manipulation on the table using INSERT/UPDATE/DELETE SQL statements.
Answer: ABC
其中的C选项在Oracle SQL Reference中也被提及,详见楼上
这个到底应该怎么实现呢?

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-12-21 03:53 , Processed in 0.053554 second(s), 20 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569