码迷,mamicode.com
首页 > 其他好文 > 详细

OCP—051试题

时间:2015-03-01 00:16:59      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:

FROM:

http://blog.itpub.net/26736162/viewspace-1252569/?page=2

http://blog.csdn.net/elearnings/article/details/10103611

1.

 

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:

Which statement is true regarding the above command? (B)

 

CREATE TABLE new_sales(prod_id, cust_id, order_date DEFAULT SYSDATE) AS

SELECT prod_id, cust_id, time_id FROM sales;

技术分享

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.

CREATE TABLE T2

(

Col1 NUMBER(2) PRIMARY KEY,

Col2 VARCHAR2(10)

);

技术分享

CREATE TABLE T3 AS SELECT * FROM T2;

技术分享技术分享

 隐式声明的NOT NULL约束(例如主键的NOT NULL约束)不会继承。
(上面的例子能说明能说明这点?)

 

Creating a Table Using a Subquery

Create a table and insert rows by combining the CREATE

TABLE statement and the AS subquery option.

CREATE TABLE table

[(column, column...)]

AS subquery;

Match the number of specified columns to the number of subquery columns.

Define columns with column names and default values.

Guidelines

The table is created with the specified column names, and the rows retrieved by the

SELECT statement are inserted into the table.

The column definition can contain only the column name and default value.

If column specifications are given, the number of columns must equal the number of

columns in the subquery SELECT list.

If no column specifications are given, the column names of the table are the same as the column

names in the subquery.

The column data type definitions and the NOT NULL constraint are passed to(被传递) the new table.

Note that only the explicit(显式的) NOT NULL constraint will be inherited. The PRIMARY KEY column will

not pass the NOT NULL feature to the new column. Any other constraint rules are not passed to

the new table. However, you can add constraints in the column definition.

 

OCP—051试题

标签:

原文地址:http://www.cnblogs.com/dogharry/p/4306380.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!