There is only one correct answer which is C.
B is incorrect because you can insert into the table without using the default value of ord_no i.e.
INSERT INTO ord_items (ord_no,item_no, qty, expiry_date)
VALUES (3,25,11, sysdate +10) ;
A. If sequence ORD_SEQ is dropped then the default value for column ORD_NO will be NULL for rows inserted into ORD_ITEMS --> False, the column is NOT NULL.
B. Any user inserting rows into table ORD_ITEMS must have been granted access to sequence ORD_SEQ --> True
C. Column ORD_NO gets the next number from sequence ORD_SEQ whenever a row is inserted into ORD_ITEMS and no explicit value is given for ORD_NO --> True
D. Sequence ORD_SEQ cycles back to 1 after every 5000 numbers and can cycle 20 times --> False, it goes back to 1 after 1.000.000...
E. Sequence ORD_SEQ is guaranteed not to generate duplicate numbers --> False, having CYCLE in the create statement, duplicates will arrive after the first cycle.
BE
I tired to run the sequence again starting from one and giving max value 10 to check if duplicate value is inserted ,
But it complains as below
insert into ord_items (ITEM_NO,QTY,EXPIRY_DATE,ORD_NO)values (1,12,'03-MAR-23',ord_seq.NEXTVAL)
*
ERROR at line 1:
ORA-00001: unique constraint (SYS.IT_PK) violated
So bC OF THE CONSTRAINY ,iT WILL NEVER BE DUPLICATED
You are getting Unique constraint because on ord_no has been specified as one of the primary key. But answer E was specific state about the sequence to guarantee no duplicate. Once CYCLE has been defined on the sequence means once reach the maximum Val it will start again at 1.
B: GRANT SELECT ON my_user.my_seq TO another_user; —to give access to others
For E create sequence and table with smaller values:
CREATE sequence ord_seq
INCREMENT BY 1
START WITH 1
MAXVALUE 1000
CYCLE
CACHE 500;
CREATE TABLE ord_items (ord_no number(1) DEFAULT ord_seq.NEXTVAL NOT NULL, item_no number(3), PRIMARY KEY (ord_no, item_no));
select * from ord_items;
insert into ord_items values(default,1); — keep entering until it will not take any more, keep going after few errors
After getting values from 1 to 9 it will give this error
“value larger than specified precision allowed for this column”
Sequence never get the chance to CYCLE so E is correct in this scenario only.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
ama
Highly Voted 3 years, 11 months agoEkos
3 years, 7 months agoSharif1
Highly Voted 3 years, 11 months agoAbdullejr
Most Recent 6 months agomamadu
1 year agoauwia
1 year agoRaNik69
1 year, 1 month ago477267
1 year, 4 months agoronie_23
3 months, 1 week agoDbi
1 year, 5 months agotrgbighero
1 year, 9 months agoalgerianphoenix
2 years, 2 months agoBM2000
2 years, 2 months agoryuah
2 years, 6 months agoGuhborges
2 years, 9 months agogabriel3600
3 years, 1 month agokawsar
3 years, 3 months agoescoletsgo1
3 years, 10 months agoNowOrNever
3 years, 12 months agoama
3 years, 11 months agoelbelgounetos
3 years, 4 months ago