how do you restrict number of rows for a particular value
in a column.For example:there is a table called
fruits,having apples,bananas ,papayas.I dont want to have
more than 100 apples in that table ,so how can u restrict
number of rows for apple to hundred?

Answer Posted / ashwin

You can create a sequence named seq_fruit as below .

create sequence seq_fruit
increment by 1
start with 1
maxvalue 100
minvalue 1
cycle
cache 10
if the current count ie currval of seq_fruit is 100 and
after this if u r inserting a new row in fruit table as
following

insert into fruit values(seq_fruit.nextval,30,40);
after the execution of this statement next value for apple
will be entered as 1 and not 101.

The cycle keyword will avoid the count of fruit column to go
beyond 100.

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a clob in sql?

730


Is inner join same as self join?

787


What is sql engine in oracle?

724


what are the different type of sql's statements ? : Sql dba

701


What trigger means?

730






what does it mean to have quoted_identifier on? : Sql dba

895


What is attribute indicator in pl sql?

722


What are the 3 types of behavioral triggers?

943


what is dbms? : Sql dba

736


How does a trigger work?

719


Is sql a microsoft product?

693


How many rows can sqlite handle?

782


What is the most common sql injection tool?

739


How do you delete data from a table?

735


How to avoid using cursors?

767