V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
工单节点使用指南
• 请用平和的语言准确描述你所遇到的问题
• 厂商的技术支持和你一样也是有喜怒哀乐的普通人类,尊重是相互的
• 如果是关于 V2EX 本身的问题反馈,请使用 反馈 节点
Kamitora
V2EX  ›  全球工单系统

使用 Data Grip 创建 MySQL 表使用 auto_increment 时,为什么该软件仍将主键单独拿出来声明?

  •  
  •   Kamitora · 2019-10-18 09:40:41 +08:00 · 2070 次点击
    这是一个创建于 1650 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Example

    create table friend_request
    (
    	friend_request_ID int auto_increment,
    	request_num int default 0 not null,
    	user_name_sent varchar(20) not null,
    	id_sent int not null,
    	id_received int not null,
    	is_received bool default 0 not null
    );
    
    alter table friend_request
    	add constraint friend_request_pk
    		primary key (friend_request_ID);
    
    

    出现如下错误

    [42000][1075] Incorrect table definition; there can be only one auto column and it must be defined as a key.
    

    要手动把语句改成这样

    	friend_request_ID int auto_increment PRIMARY KEY,
    
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3780 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 10:34 · PVG 18:34 · LAX 03:34 · JFK 06:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.