1

I am creating a database containing a single table which contains around 16 columns. The upper limit to the number of rows has been set at 10000 rows - decided after analyzing the amount of space it consumes. There are two possible strategies I can follow for forcing this limit:

  1. Before inserting any row into the table, I check the size of the table and then insert only if the current size if less than 10000.
  2. Putting a configuration limit (either through some external configuration file or through some dynamic parameter) on the maximum number of rows that can be added for a single table

Of the above, I prefer the option 2 primarily because that reduces the effort of checking the size for every insert (and my table is insert intensive, reading is occasional). I have been searching for a way to set the upper limit on the number of rows but couldn't come up with a plausible solution. It would certainly be most useful if this limit can be dynamically set (for example using the sqlite3_limit() like API), but, an /etc/* like configuration file too would serve the purpose.

Can someone please help me with this and let me know if this is even possible?

(Working on SQLite 3.7.7.1 and Linux [SLES 11] Box).

Shrey
  • 659
  • 2
  • 5
  • 15
  • possible duplicate of [Limit a sqlite Table's Maximum Number of Rows](http://stackoverflow.com/questions/2035670/limit-a-sqlite-tables-maximum-number-of-rows) – luvieere Aug 29 '11 at 07:47
  • A third option: http://www.sqlite.org/lang_createtrigger.html – Tim Aug 29 '11 at 10:15
  • @luvieere, this is very similar to the question in the link you posted. Only difference being, I am looking for a configuration parameter. In the question poster in the link you provided, the aim is to get a SQL query based mechanism. And it now seems that no such configurable parameters exists. – Shrey Aug 31 '11 at 14:30
  • Thanks @Tim. Unfortunately, I am using the C interface wherein the action to be taken when the number of rows are deleted is driven by a independent module (for example, restricting insertions or deletion). In case of trigger, I would have to use a pre-defined method (like deleting) while creating the DB. Thanks for your comment anyways. – Shrey Aug 31 '11 at 14:32

0 Answers0