Jakob
Jakob

Reputation: 4854

what is wrong with this sql table creating (foreign key issue)

Error Number: 1005

Can't create table 'pyro_urbfot.default_wishlist' (errno: 150)

CREATE TABLE IF NOT EXISTS `default_wishlist` (
  `id` int(8) unsigned NOT NULL auto_increment,
  `uid` int(11) NOT NULL,
  `position` int(8) unsigned NOT NULL default '0',
  `url` varchar(30),
  `text` varchar(255) collate utf8_unicode_ci NOT NULL default '',
  `dt_added` timestamp NOT NULL default CURRENT_TIMESTAMP,
  PRIMARY KEY  (`id`),
  KEY `position` (`position`),
  KEY `uid` (`uid`),
  FOREIGN KEY (`uid`)
  REFERENCES `default_users`(`id`)
  ON DELETE CASCADE
  ON UPDATE CASCADE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Upvotes: 1

Views: 121

Answers (1)

Martin Smith
Martin Smith

Reputation: 453037

Your script works fine for me when I create this table first

CREATE TABLE `default_users`
(
`id` int primary key
)

Please check that the table exists and you are using compatible datatypes.

Upvotes: 1

Related Questions