MySQL Forums
Forum List  »  InnoDB

Re: ERROR 1005: Can't create table (errno: 150)
Posted by: C Fischer
Date: May 30, 2008 07:43AM

Hello all,

I found out problems with Integer as PK,FK.

If you change the columns DEC(10) to INT(11) you will get an 1005-150.

Have anybody an idea why? I is this a bug?

MySQL 5.124

-- phpMyAdmin SQL Dump
-- version 2.11.6
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Erstellungszeit: 30. Mai 2008 um 14:13
-- Server Version: 5.1.24
-- PHP-Version: 5.2.6

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

-- --------------------------------------------------------

show engine innodb status;
DROP database if exists skeleton;
show warnings;
CREATE DATABASE `skeleton`;
show warnings;
use skeleton;


DROP TABLE IF EXISTS `skeleton_dim1`;
CREATE TABLE IF NOT EXISTS `skeleton_dim1` (
`id` DEC(10) NOT NULL ,
`objID` int(11) NOT NULL DEFAULT '-1' ,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

DROP TABLE IF EXISTS `skeleton_dim2`;
CREATE TABLE IF NOT EXISTS `skeleton_dim2` (
`id` DEC(10) NOT NULL,
`objID` int(11) NOT NULL DEFAULT '-1' ,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


-- --------------------------------------------------------


DROP TABLE IF EXISTS skeleton_fakt;
CREATE TABLE IF NOT EXISTS skeleton_fakt (
`id` int(11) NOT NULL AUTO_INCREMENT,
`objID` int(11) NOT NULL DEFAULT '-1' COMMENT 'DWH-ID',
`fk_skeleton_dim1` DEC(10) NOT NULL DEFAULT '-2' COMMENT 'Zeigt auf Dimension',
`fk_skeleton_dim2` DEC(10) NOT NULL DEFAULT '-2' COMMENT 'Zeigt auf Dimension',
PRIMARY KEY (`id`),
KEY `fk_skeleton_fakt_skeleton_dim2` (`fk_skeleton_dim2`),
KEY `fk_skeleton_fakt_skeleton_dim2_obj` (`objID`),
KEY `fk_skeleton_fakt_skeleton_dim1` (`fk_skeleton_dim1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

alter table skeleton_fakt add constraint fk_dim1 foreign key (fk_skeleton_dim1) references skeleton_dim1(id);
show warnings;
-- show engine innodb status;
alter table skeleton_fakt add constraint fk_dim2 foreign key (fk_skeleton_dim2) references skeleton_dim2(id);
show warnings;
-- show engine innodb status;

Options: ReplyQuote


Subject
Views
Written By
Posted
648002
March 24, 2005 01:20PM
5346
October 09, 2012 09:48PM
3616
December 19, 2011 10:13PM
9061
May 09, 2006 06:01PM
8243
November 15, 2006 02:05PM
7286
T D
February 01, 2008 06:47AM
Re: ERROR 1005: Can't create table (errno: 150)
10640
May 30, 2008 07:43AM
9098
August 27, 2008 08:08AM
9602
December 03, 2008 10:15AM
6073
May 01, 2009 07:39AM
3333
August 29, 2011 04:46PM
4906
s l
December 15, 2009 01:48PM
4836
December 22, 2009 02:54AM
3158
February 18, 2011 08:55AM
3752
May 24, 2011 10:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.