34.You created an ORDERS table with the following description:
2016-01-26 15:33
531 查看
34.You created an ORDERS table with the following description:
name Null Type
ORD_ID NOT NULL NUMBER(2)
CUST_ID NOT NULL NUMBER(3)
ORD_DATE NOT NULL DATE
ORD_AMOUNT NOT NULL NUMBER (10,2)
You inserted some rows in the table. After some time, you want to alter the table by creating the
PRIMARY KEY constraint on the ORD_ID column. Which statement is true in this scenario?
A.You cannot have two constraints on one column.
B.You cannot add a primary key constraint if data exists in the column.
C.The primary key constraint can be created only at the time of table creation .
D.You can add the primary key constraint even if data exists, provided that there are no duplicate values.
答案:D
解析:
A:不能在一个列上创建2个约束,显然不对,not null + unique ==primary key
B:如果一个列上已经有数据了,那么不能增加主键约束,这个也是错误的,主键相当于not nul和unique ,只要数据不违反这两种那么就可以增加
C:主键只能在创建表的时候增加,这个也是错误的
D:正确
name Null Type
ORD_ID NOT NULL NUMBER(2)
CUST_ID NOT NULL NUMBER(3)
ORD_DATE NOT NULL DATE
ORD_AMOUNT NOT NULL NUMBER (10,2)
You inserted some rows in the table. After some time, you want to alter the table by creating the
PRIMARY KEY constraint on the ORD_ID column. Which statement is true in this scenario?
A.You cannot have two constraints on one column.
B.You cannot add a primary key constraint if data exists in the column.
C.The primary key constraint can be created only at the time of table creation .
D.You can add the primary key constraint even if data exists, provided that there are no duplicate values.
答案:D
解析:
A:不能在一个列上创建2个约束,显然不对,not null + unique ==primary key
B:如果一个列上已经有数据了,那么不能增加主键约束,这个也是错误的,主键相当于not nul和unique ,只要数据不违反这两种那么就可以增加
C:主键只能在创建表的时候增加,这个也是错误的
D:正确
相关文章推荐
- window上连接集群跑hadoop问题之java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.
- iOS----JSON解析
- Windows运行Hadoop遇到的问题
- oracle改变ip后的问题
- 【HDU】 1542 Atlantis
- 《深入理解OpenCV》——ALPR
- 使用awk进行简单文件处理对文件分割求平均
- 优先队列 (2)
- Prim算法-最小生成树(附题:HDU-1875 畅通工程再续)
- LAMP环境配置-Apache的深入理解
- js 闭包
- JavaScript学习笔记2--DOM、运动
- 求两整数的最大公约数(递归法)和最小公倍数
- sparkSQL metaData配置到Mysql
- ui网址
- 用elasticsearch和kibana 进行简单的实时数据报表分析
- 命令行进度条
- SDWebImage的使用与原理
- 美团Android自动化之旅—生成渠道包
- 正则表达式30分钟入门教程