Which CREATE TABLE statement is valid?

Which CREATE TABLE statement is valid?

Which CREATE TABLE statement is valid?

A.
CREATE TABLE ord_details
(ord_no NUMBER(2) PRIMARY KEY,
item_no NUMBER(3) PRIMARY KEY,
ord_date DATE NOT NULL);

B.
CREATE TABLE ord_details
(ord_no NUMBER(2) UNIQUE, NOT NULL,
item_no NUMBER(3),
ord_date DATE DEFAULT SYSDATE NOT NULL);

C.
CREATE TABLE ord_details
(ord_no NUMBER(2) ,
item_no NUMBER(3),
ord_date DATE DEFAULT NOT NULL,
CONSTRAINT ord_uq UNIQUE (ord_no),
CONSTRAINT ord_pk PRIMARY KEY (ord_no));

D.
CREATE TABLE ord_details
(ord_no NUMBER(2),
item_no NUMBER(3),
ord_date DATE DEFAULT SYSDATE NOT NULL,
CONSTRAINT ord_pk PRIMARY KEY (ord_no, item_no));



Leave a Reply 26

Your email address will not be published. Required fields are marked *


Mike

Mike

For option D: isn’t it incorrect since you cannot use SYSDATE as the DEFAULT Date value?

Miguel

Miguel

It´s correct, because don´t have clause CHECK, and only doing inserts with default sysdate

elman

elman

hi. But what is the problem with a ?

Eric Sacramento

Eric Sacramento

They tried to created a compound primary key, but the syntax is not correct. Every table must have just one PK.

Correct way to create a compound PK.
CONSTRAINT ord_pk PRIMARY KEY (ord_no, item_no));

Eric Sacramento

Eric Sacramento

They tried to created a compound primary key, but the syntax is not correct.

Correct way to create a compound PK.
CONSTRAINT ord_pk PRIMARY KEY (ord_no, item_no));

elman

elman

does constraint word absent ?

user

user

A is incorrect: only one primary key allowed per table.

elman

elman

yes yes yes sureeeee

abhishek

abhishek

Why isnt B correct??
It is not necessary that each table has a primary key.

kongo

kongo

B is not correct because of that line:
ord_no NUMBER(2) UNIQUE, NOT NULL,
Unique + no null = PK 🙂

And because of that D is more valid answer.

user2

user2

B is not correct because of the comma (,) typed between UNIQUE and NOT NULL.

Unique + not null does NOT indicates it is PK. The table does NOT have to have a PK. Just a simple syntax error (for having an extra comma)

john

john

c is also corect i think.??

KARTHIK B S

KARTHIK B S

Thanks Alvin2201 for clarifying the doubt on indexing 🙂

rca ieftin

rca ieftin

Pretty great post. I simply came across your weblog and planned to mention that I’ve really enjoyed surfing around your site posts. After all I’ll be subscribing with your rss feed and I am hoping you are submitting again soon!|
rca ieftin http://goo.gl/6GqA7S

Google

Google

Every as soon as inside a whilst we pick out blogs that we read. Listed below are the most recent internet sites that we pick out.

Google

Google

Just beneath, are several completely not related web sites to ours, however, they may be certainly worth going over.

SEO services in Lahore

SEO services in Lahore

Sites of interest we’ve a link to

access garage doors

access garage doors

usually posts some really exciting stuff like this. If you are new to this site

Google

Google

Here are several of the sites we suggest for our visitors.

SEO services in Lahore

SEO services in Lahore

please stop by the web sites we adhere to, which includes this a single, as it represents our picks in the web

paper fans

paper fans

we came across a cool web-site that you simply might get pleasure from. Take a look in case you want

Xavier Boleware

Xavier Boleware

Awesome article.Much thanks again. Will read on…