douwei1930 2015-07-22 15:24
浏览 46
已采纳

基于其他列组合的MySQL InnoDB自动增量列

I am making a system where users can upload any file they want, and not use it to execute any kind of code. As a part of that, I rename every file, and store its original name in a MySQL table. This table contains the id of the user who uploaded it, and a unique id of the upload. Currently I am doing it like this:

CREATE TABLE `uploads` (
    `user_id` INT(11) NOT NULL,
    `upload_id` INT(11) NOT NULL AUTO_INCREMENT,
    `original_name` VARCHAR(30) NOT NULL,
    `mime_type` VARCHAR(30) NOT NULL,
    `name` VARCHAR(50) NOT NULL,
    PRIMARY KEY (`user_id`, `upload_id`)
) ENGINE=MyISAM;

This means I will always have a unique combination of user_id and upload_id, and every users first upload has an id of 1. However I heard MyISAM is old, and i should rather use InnoDB. Is there any way I can achieve this in InnoDB?

  • 写回答

1条回答 默认 最新

  • douzhuo2002 2015-07-22 16:00
    关注

    The biggest problem with MyISAM tables is that they are not transactional. From what you say, you will only be creating records and then reading them (possibly deleting them later) but there will be little or no editing. This situation is what MyISAM was designed for, it is fast for mostly read only records. Personally I see no advantage converting to InnoDB.

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

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料