doulian4762 2014-01-22 17:35
浏览 16
已采纳

sqlite增量键超过2个表

Im working on a pos system based on sqlite. One table contains all orders/buys. Every night the system should copy all orders to an different table in a different database, because otherwise the orders table will become too heavy (monthly about 15000 new rows) and the whole system will become too slow.

My problem is, that when i copy the daily orders into the backup database, im loosing my last autoincrement value. That means: sqlite is starting again with 1. But i need a unique ID for the orders over 2 databases/tables?

Does somebody has an idea, how i can force sqlite to not reset the last autoincrement value, when deleting all rows?

  • 写回答

1条回答 默认 最新

  • douguanya4248 2014-01-22 17:50
    关注
    CREATE TABLE backup_table(
      tableflag integer not null,   
      autoincid integer not null,  
      column-n   ....,
      ....., 
      PRIMARY KEY (tableflag , autoincid)
    );
    

    and copy the original autoincrement value from the original table to your backup table and use a special flag for every table you want to unite

    Otherwise you could insert a row with the highest autoincrement value plus 1 of your backup table after the deletion as first row, Then sqlite will just increment that value.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案