1

我收到了这个错误

#1005 - Can't create table 'tcf26469_sklepyinternetowe.ps_auctions_rutcom_bids' (errno: 150)

当我尝试创建表时。我在 stackoverflow 上阅读了很多结果,但我看不到我的错误在哪里。我检查类型,创建密钥,尝试 CONSTRAINT :(。我的 Db 创建

'CREATE TABLE IF NOT EXISTS 'ps_auctions_rutcom` (
        `id_auctions_rutcom` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
        `id_product` INT( 11 ) unsigned NOT NULL,
        `id_customer` INT( 11 ) unsigned NOT NULL,
        `start_price` float unsigned NOT NULL,
        `min_price` float unsigned,
        `buy_now_price` float unsigned,
        `min_bit` float unsigned DEFAULT \'1\',
        `actual_bid_price` float unsigned,
        `max_bid_price` float unsigned,
        `max_bid_price_id_customer` INT( 11 ) unsigned NOT NULL,
        `start_date` DATETIME NOT NULL,
        `finish_date` DATETIME NOT NULL,
        `active` tinyint(1) unsigned NOT NULL DEFAULT \'1\',
        `position` INT( 11 ) unsigned NOT NULL DEFAULT \'0\',
        `finish` INT( 11 ) unsigned NOT NULL DEFAULT \'0\',
        PRIMARY KEY (`id_auctions_rutcom`)
    ) ENGINE = InnoDB DEFAULT CHARSET=utf8

表什么使用 FOREIGN KEY

CREATE TABLE IF NOT EXISTS `ps_auctions_rutcom_bids` (
    `id_auction_bid` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
    `id_auctions_rutcom` INT( 11 ) UNSIGNED NOT NULL,
    `id_customer` INT( 11 ) unsigned NOT NULL,
    `bid_value` float unsigned,
    PRIMARY KEY (`id_auction_bid`),
    Key `idauction` (`id_auctions_rutcom`),
    CONSTRAINT `idauction`
    FOREIGN KEY (`id_auctions_rutcom`) REFERENCES auctions_rutcom  ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8

我做错了什么?错误在哪里?

4

1 回答 1

1

你应该使用ps_auctions_rutcom 而不是auctions_rutcom

CREATE TABLE IF NOT EXISTS `ps_auctions_rutcom_bids` (
        `id_auction_bid` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
        `id_auctions_rutcom` INT( 11 ) UNSIGNED NOT NULL,
        `id_customer` INT( 11 ) unsigned NOT NULL,
        `bid_value` float unsigned,
        PRIMARY KEY (`id_auction_bid`),
        Key `idauction` (`id_auctions_rutcom`),
        CONSTRAINT `idauction`
        FOREIGN KEY (`id_auctions_rutcom`) REFERENCES ps_auctions_rutcom  ON DELETE CASCADE

    ) ENGINE = InnoDB DEFAULT CHARSET=utf8
于 2013-08-06T10:49:49.663 回答