33.You want to create an ORD_DETAIL table to store details for an order placed having the following

33.You want to create an ORD_DETAIL table to store details for an order placed having the following 
1) The order ID will be unique and cannot have null values.
2) The order date cannot have null values and the default should be the current date.
3) The order amount should not be less than 50.
4) The order status will have values either shipped or not shipped.
5) The order payment mode should be cheque, credit card, or cash on delivery (COD).
Which is the valid DDL statement for creating the ORD_DETAIL table?
A.CREATE TABLE ord_details(
         ord_id NUMBER(2) CONSTRAINT ord_id_nn NOT NULL,
         ord_date DATE DEFAULT SYSDATE NOT NULL,
         ord_amount NUMBER(5, 2) CONSTRAINT ord_amount_min CHECK (ord_amount > 50),
         ord_status VARCHAR2(15) CONSTRAINT ord_status_chk CHECK (ord_status IN ('Shipped', 'Not Shipped')),
         ord_pay_mode VARCHAR2(15) CONSTRAINT ord_pay_chk  CHECK (ord_pay_mode IN ('Cheque', 'Credit Card','Cash On Delivery'))
         );
B.CREATE TABLE ord_details(
         ord_id NUMBER(2) CONSTRAINT ord_id_uk UNIQUE NOT NULL, 
         ord_date DATE DEFAULT SYSDATE NOT NULL,
         ord_amount NUMBER(5, 2) CONSTRAINT ord_amount_min CHECK (ord_amount > 50),
         ord_status VARCHAR2(15) CONSTRAINT ord_status_chk CHECK (ord_status IN ('Shipped', 'Not Shipped')),
         ord_pay_mode VARCHAR2(15) CONSTRAINT ord_pay_chk CHECK (ord_pay_mode IN ('Cheque', 'Credit Card','Cash On Delivery'))
         );
C.CREATE TABLE ord_details(
         ord_id NUMBER(2) CONSTRAINT ord_id_pk PRIMARY KEY,
         ord_date DATE DEFAULT SYSDATE NOT NULL,
         ord_amount NUMBER(5, 2) CONSTRAINT ord_amount_min CHECK (ord_amount >= 50),
         ord_status VARCHAR2(15) CONSTRAINT ord_status_chk CHECK (ord_status IN ('Shipped', 'Not Shipped')),
         ord_pay_mode VARCHAR2(15) CONSTRAINT ord_pay_chk  CHECK (ord_pay_mode IN ('Cheque', 'Credit Card','Cash On Delivery')));
D.CREATE TABLE ord_details(
         ord_id NUMBER(2),
         ord_date DATE NOT NULL DEFAULT SYSDATE,
         ord_amount NUMBER(5, 2) CONSTRAINT ord_amount_min CHECK (ord_amount >= 50),
         ord_status VARCHAR2(15) CONSTRAINT ord_status_chk CHECK (ord_status IN ('Shipped', 'Not Shipped')),
         ord_pay_mode VARCHAR2(15) CONSTRAINT ord_pay_chk  CHECK (ord_pay_mode IN ('Cheque', 'Credit Card','Cash On Delivery')));
答案:C
解析:
通过题目可以知道
1.order ID唯一且不能为null,那么order id 可能为unique key 和primary key的组合也可能为primary key,排除A,D
2.order date不能为null,且默认值为当前日期,那么not null 或 primary 和默认值的组合,ABCD都满足
3.order amount 应该不小于50,那么应该是check 约束>=50,排除A,B
4.order status 为shipped 或 not shipped,那么check约束,都满足
5.order payment mode为cheque 或 credit card 或 cash on delivery,那么check约束,都满足
因此,选择C        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值