OCP-1Z0-051 第1题 CTAS语句建表注意事项
来源:互联网 发布:javascript我要自学网 编辑:程序博客网 时间:2024/06/10 12:49
一、 原题
答案 B
二、题目翻译:
三、题目解析:
显式的NOT NULL约束自动会带到新表。
NOT NULL constraints that were implicitly created by Oracle Database on columns of the selected table (for example, for primary keys) are not carried over to the new table.
隐式的NOT NULL约束不会带到新表,如主键。
In addition, primary keys, unique keys, foreign keys, check constraints, partitioning criteria, indexes, and column default values are not carried over to the new table.
另外,主键,唯一,外键,check约束,分区,索引以及列的默认值不会带到新表。
If the selected table is partitioned, then you can choose whether the new table will be partitioned the same way, partitioned differently, or not partitioned. Partitioning is not carried over to the new table. Specify any desired partitioning as part of the CREATE TABLE statement before the AS subquery clause.
在新表上可以选择是否像旧表那样分区,或者不同的分区形式,或者不分区的表,分区不会被带到新表中, 在AS subquery句之前指定。
View the Exhibit and examine the structure of the SALES, CUSTOMERS, PRODUCTS, and TIMES tables.
The PROD_ID column is the foreign key in the SALES table, which references the PRODUCTS table.
Similarly, the CUST_ID and TIME_ID columns are also foreign keys in the SALES table referencing the CUSTOMERS and TIMES tables, respectively.
Evaluate the following CREATE TABLE command:
CREATE TABLE new_sales(prod_id, cust_id, order_date DEFAULT SYSDATE)
AS
SELECT prod_id, cust_id, time_id
FROM sales;
Which statement is true regarding the above command?
A. The NEW_SALES table would not get created because the DEFAULT value cannot be specified in the column definition.
B. The NEW_SALES table would get created and all the NOT NULL constraints defined on the specified columns would be passed to the new table.
C. The NEW_SALES table would not get created because the column names in the CREATE TABLE command and the SELECT clause do not match.D. The NEW_SALES table would get created and all the FOREIGN KEY constraints defined on the specified columns would be passed to the new table
答案 B
二、题目翻译:
看下图中SALES, CUSTOMERS, PRODUCTS, and TIMES这几张表的结构,SALES表有一个外键列PROD_ID,关联到PRODUCTS表。类似地,CUST_ID and TIME_ID 列也是SALES表的外键列,分别关联到表CUSTOMERS和表TIMES,
下面的这条CREATE TABLE建表命令:
CREATE TABLE new_sales(prod_id, cust_id, order_date DEFAULT SYSDATE)
AS
SELECT prod_id, cust_id, time_id
FROM sales;
关于这个命令,下面哪一种说法是正确的:
A.NEW_SALES这张表不能创建成功,因为列定义时,不能指定默认值。
B.NEW_SALES这张表能创建成功,并且所有 指定列上的已定义的非空约束会带到新表。
C.NEW_SALES表不能创建成功,因为CREATE TABLE命令中的列名与SELECT子句中的列名不匹配。
D.NEW_SALES表可以创建成功,并且所有指定列上的已定义的外键约束会带新表。
三、题目解析:
使用CREATE TABLE..AS..语句创建表时,原表列上如果有显式非空约束会传递给新表,其它约束都不会带到新表。
11.2联机文档中的关于CREATE TABLE 的 AS subquery 里的具体描述:
http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_7002.htm#SQLRF54626
摘录如下:
显式的NOT NULL约束自动会带到新表。
NOT NULL constraints that were implicitly created by Oracle Database on columns of the selected table (for example, for primary keys) are not carried over to the new table.
隐式的NOT NULL约束不会带到新表,如主键。
In addition, primary keys, unique keys, foreign keys, check constraints, partitioning criteria, indexes, and column default values are not carried over to the new table.
另外,主键,唯一,外键,check约束,分区,索引以及列的默认值不会带到新表。
If the selected table is partitioned, then you can choose whether the new table will be partitioned the same way, partitioned differently, or not partitioned. Partitioning is not carried over to the new table. Specify any desired partitioning as part of the CREATE TABLE statement before the AS subquery clause.
在新表上可以选择是否像旧表那样分区,或者不同的分区形式,或者不分区的表,分区不会被带到新表中, 在AS subquery句之前指定。
0 0
- OCP-1Z0-051 第1题 CTAS语句建表注意事项
- OCP-1Z0-051 第167题 DELETE语句注意事项
- OCP-1Z0-051 第158题 select... for update语句注意事项
- OCP-1Z0-051 第38题 视图注意事项
- OCP-1Z0-051 第40题 视图的注意事项
- OCP-1Z0-051 第41题 视图的注意事项
- OCP-1Z0-051 第42题 视图的注意事项
- OCP-1Z0-051 第135题 子查询注意事项
- OCP-1Z0-051 第170题 DELETE的注意事项
- OCP-1Z0-051 第175题 savepoint的注意事项
- OCP-1Z0-051 第10题
- OCP-1Z0-051 第54题
- OCP-1Z0-051 第60题
- OCP-1Z0-051 第9题 集合操作INTERSECT注意事项
- OCP-1Z0-051 第45题 SEQUENCE(序列)的注意事项
- OCP-1Z0-051 第64题 order by使用别名注意事项
- OCP-1Z0-051 第108题 COUNT函数使用注意事项
- OCP-1Z0-051 第139题 子查询的注意事项
- qqqqqq
- 一个应届计算机毕业生的2012求职之路
- Cocos2D-x游戏开发之二十:添加可以吃的精灵
- java享元模式
- mysql触发器
- OCP-1Z0-051 第1题 CTAS语句建表注意事项
- 高速连接数据源BoneCP
- Fiddler工具使用报告
- Struts2 -- struts.xml配置总结
- Facade(门面模式)
- 浅析gcc、arm-linux-gcc和arm-elf-gcc的关系
- HDU 2087 剪花布条(KMP:贪心)
- 在redhat上安装QT4.8.5
- 面试题十 二进制中1的个数