Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Mention what is the plv (pl/vision) package offers?

1164


What is mutating sql table?

1160


What is sql query optimization?

1195


Can 2 queries be executed simultaneously in a distributed database system?

1194


How much ram can sql express use?

1042


Enlist the data types that can be used in pl/sql?

1112


what are different types of collation sensitivity? : Sql dba

1122


What is sql and also describe types of sql statements?

1114


What is the difference between Union and Union all. Which is faster.

1441


How do temporal tables work?

1021


how many triggers are allowed in mysql table? : Sql dba

1107


what is log shipping? : Sql dba

1167


How do I view tables in mysql?

1032


What is information schema in sql?

1119


What is program debugging?

1345