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

What is a table in a database?

1045


Is it possible to update views?

959


How does one load ebcdic data? : aql loader

1175


How much does a sql dba make? : SQL DBA

948


How can a pl sql block be executed?

947


what are set operators in sql? : Sql dba

1054


mention if it is possible to import data directly from t-sql commands without using sql server integration services? If yes, what are the commands? : Transact sql

1042


what is datawarehouse? : Sql dba

1017


What is Difference Between Unique and Primary Key Constraints?

1107


Is sqlite thread safe?

1054


Name the operator which is used in the query for pattern matching?

954


Why are sql stored procedures used?

1056


What is materialized view. What are different methods of refresh?

1393


Why we use triggers in mysql?

992


Which are the different types of indexes in sql?

1061