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
Mention what is the plv (pl/vision) package offers?
What is mutating sql table?
What is sql query optimization?
Can 2 queries be executed simultaneously in a distributed database system?
How much ram can sql express use?
Enlist the data types that can be used in pl/sql?
what are different types of collation sensitivity? : Sql dba
What is sql and also describe types of sql statements?
What is the difference between Union and Union all. Which is faster.
How do temporal tables work?
how many triggers are allowed in mysql table? : Sql dba
what is log shipping? : Sql dba
How do I view tables in mysql?
What is information schema in sql?
What is program debugging?