Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1062130
  • 博文数量: 239
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 3618
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-12 13:17
文章分类

全部博文(239)

文章存档

2021年(1)

2016年(1)

2015年(30)

2014年(91)

2013年(116)

分类: Oracle

2015-03-19 23:08:14

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:
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.
Answer: B
解析:

SQL> create table SALES(prod_id number not null,cust_id number not null,time_id date not null,channel_id number not null,promo_id number not null,quantity_sold number(10,2) not null);

Table created.

SQL> CREATE TABLE new_sales(prod_id, cust_id, order_date DEFAULT SYSDATE) AS SELECT prod_id, cust_id, time_id FROM sales;

Table created.

SQL> DESC new_sales;
 Name        Null?    Type
 ----------------------------------------- -------- ----------------------------
 PROD_ID       NOT NULL NUMBER
 CUST_ID       NOT NULL NUMBER
 ORDER_DATE       NOT NULL DATE
可以看出NOT NULL约束可以传递给子表;

阅读(607) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~