ITPub博客

首页 > 数据库 > Oracle > 1Z0-053 V13.02 Q17

1Z0-053 V13.02 Q17

原创 Oracle 作者:cow977 时间:2016-08-12 12:21:19 0 删除 编辑
17.The INV_HISTORY table is created using the command:
SQL>CREATE TABLE INV_HISTORY (inv_no NUMBER(3), inv_date DATE, inv_amt NUMBER(10,2))
partition by range (inv_date) interval (numtoyminterval(1,'month'))
(partition p0 values less than (to_date('01-01-2005','dd-mm-yyyy')),
partition p1 values less than (to_date('01-01-2006','dd-mm-yyyy')));
The following data has been inserted into the INV_HISTORY table :
INV_NO INV_DATE INV_AMT
1 30-dec-2004 1000
2 30-dec-2005 2000
3 1-feb-2006 3000
4 1-mar-2006 4000
5 1-apr-2006 5000
You would like to store the data belonging to the year 2006 in a single partition and issue the command:
SQL> ALTER TABLE inv_history MERGE PARTITIONS FOR(TO_DATE('15-feb-2006','dd-mon-yyyy')), FOR(TO_DATE('15-apr-2006')) INTO PARTITION sys_py;
What would be the outcome of this command?
A. It executes successfully, and the transition point is set to '1-apr-2006'.
B. It executes successfully, and the transition point is set to '15-apr-2006'.
C. It produces an error because the partitions specified for merging are not adjacent.
D. It produces an error because the date values specified in the merge do not match the date values stored in the table.
Answer: C

您想把属于2006年的数据存储在一个单一的分区,并发出分区合并命令,此命令的结果会是什么?

C、它会产生一个错误,因为指定用于合并的分区不相邻。

SQL> CREATE TABLE INV_HISTORY (inv_no NUMBER(3), inv_date DATE, inv_amt
  2  NUMBER(10,2))
  3  partition by range (inv_date) interval (numtoyminterval(1,'month'))
  4  (partition p0 values less than (to_date('01-01-2005','dd-mm-yyyy')),
  5  partition p1 values less than (to_date('01-01-2006','dd-mm-yyyy')));

表已创建。

SQL> insert into INV_HISTORY values (1,'30-dec-2004',1000);
insert into INV_HISTORY values (1,'30-dec-2004',1000)
                                  *
第 1 行出现错误:
ORA-01843: 无效的月份


SQL> insert into INV_HISTORY values (1,'30-12-2004',1000);
insert into INV_HISTORY values (1,'30-12-2004',1000)
                                  *
第 1 行出现错误:
ORA-01843: 无效的月份


SQL> insert into INV_HISTORY values (1,to_date('30-12-2004','dd-mm-yyyy'),1000);

已创建 1 行。

SQL> insert into INV_HISTORY values (2,to_date('30-12-2005','dd-mm-yyyy'),2000);

已创建 1 行。

SQL> insert into INV_HISTORY values (3,to_date('1-feb-2006','dd-mon-yyyy'),3000);
insert into INV_HISTORY values (3,to_date('1-feb-2006','dd-mon-yyyy'),3000)
                                          *
第 1 行出现错误:
ORA-01843: 无效的月份


SQL> insert into INV_HISTORY values (3,to_date('1-2-2006','dd-mm-yyyy'),3000);

已创建 1 行。

SQL> insert into INV_HISTORY values (4,to_date('1-3-2006','dd-mm-yyyy'),4000);

已创建 1 行。

SQL> insert into INV_HISTORY values (5,to_date('1-4-2006','dd-mm-yyyy'),5000);

已创建 1 行。

SQL> select * from INV_HISTORY;

    INV_NO INV_DATE          INV_AMT
---------- -------------- ----------
         1 30-12月-04           1000
         2 30-12月-05           2000
         3 01-2月 -06           3000
         4 01-3月 -06           4000
         5 01-4月 -06           5000

SQL> select * from INV_HISTORY partition(p0);

    INV_NO INV_DATE          INV_AMT
---------- -------------- ----------
         1 30-12月-04           1000

SQL> select * from INV_HISTORY partition(p1);

    INV_NO INV_DATE          INV_AMT
---------- -------------- ----------
         2 30-12月-05           2000

SQL> ALTER TABLE inv_history MERGE PARTITIONS FOR(TO_DATE('15-2月-2006','dd-mon-yyyy')), FOR(TO_DATE('15-4月-2006','dd-mon-yyyy')) INTO PARTITION sys_py;
ALTER TABLE inv_history MERGE PARTITIONS FOR(TO_DATE('15-2月-2006','dd-mon-yyyy')), FOR(TO_DATE('15-4月-2006','dd-mon-yyyy')) INTO PARTITION sys_py
*
第 1 行出现错误:
ORA-14274: 要合并的分区不相邻

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

上一篇: 1Z0-053 V13.02 Q13
下一篇: 1Z0-053 V13.02 Q21
请登录后发表评论 登录
全部评论

注册时间:2011-03-02

  • 博文量
    698
  • 访问量
    893942