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.

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

报告相同问题?

悬赏问题

  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?