简体   繁体   English

MySQL-1075错误的表格定义,只能有一个自动列,必须将其定义为键

[英]MySQL - 1075 Incorrect table definition, there can be only one auto column and it must be defined as a key

I have the following code: 我有以下代码:

use Phinx\Migration\AbstractMigration;

class CreateNewTableForJobListLanguages extends AbstractMigration
{
    /**
    * Migrate up.
    */
    public function up()
    {
        $this->execute('
        CREATE TABLE `v2_joblist_languages` (
        `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 
        `joblist_id` int(11) NULL,
        `language_id` int(11) NULL,
        FOREIGN KEY (`joblist_id`) REFERENCES `v2_job_alerts` (`id`),
        FOREIGN KEY (`language_id`) REFERENCES `v2_languages` (`id`))
    ');
}

When trying to migrate, I get the following error: 尝试迁移时,出现以下错误:

SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key

Broke my head trying to solve it, and understand why is it happening. 试图解决这个问题,让我震惊了,明白为什么会这样。 Grateful for any assistance, thanks in advance. 感谢您的帮助,在此先感谢。

This is a many:many mapping table? 这是一个多对多映射表? Is there really any need for id ? 真的需要id吗? I doubt it; 我对此表示怀疑; get rid of it. 摆脱它。

Also provide PRIMARY KEY(joblist_id), language_id), INDEX(language_id, joblist_id) 还提供PRIMARY KEY(joblist_id), language_id), INDEX(language_id, joblist_id)

Do you really want the two columns to be NULLable ? 您是否真的希望这两NULLable I doubt it. 我对此表示怀疑。

More tips on many:many: http://mysql.rjweb.org/doc.php/index_cookbook_mysql#many_to_many_mapping_table 关于以下方面的更多技巧:许多: http//mysql.rjweb.org/doc.php/index_cookbook_mysql#many_to_many_mapping_table

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误1075:表定义不正确; 只能有一个自动列,它必须被定义为一个键(使用 gorm 和 mysql) - Error 1075: Incorrect table definition; there can be only one auto column and it must be defined as a key (using gorm and mysql) 错误1075:错误的表格定义; 只能有一个自动列,并且必须将其定义为键 - ERROR 1075: Incorrect table definition; there can be only one auto column and it must be defined as a key Phpmyadmin#1075-错误的表定义; 只能有一个自动列,并且必须将其定义为键 - Phpmyadmin #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key ERROR 1075 表定义不正确; 只能有一个自动列,并且必须将其定义为键 - ERROR 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key #1075-错误的表格定义; 只能有一个自动列,并且必须将其定义为键 - #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key 导入WordPress数据库 - #1075 - 表定义不正确;只能有一个自动列,必须将其定义为键 - Importing WordPress Database - #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key "<i>#1075 - Incorrect table definition;<\/i> #1075 - 表定义不正确;<\/b> <i>there can be only one auto column and it must be defined as a key<\/i>只能有一个自动列,并且必须将其定义为键<\/b>" - #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key SQLSTATE[42000]:语法错误或访问冲突:1075 不正确的表定义; 只能有一个自动列,并且必须将其定义为键 - SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key MySQL错误:错误的表格定义; 只能有一个自动列,并且必须将其定义为键 - MySQL error: Incorrect table definition; there can be only one auto column and it must be defined as a key Data Nucleus-MySql错误的表定义; 只能有一个自动列,并且必须将其定义为关键错误 - Data Nucleus-MySql Incorrect table definition; there can be only one auto column and it must be defined as a key error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM