Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Mysql - ERROR 1005 at line 27: Can't create table....
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
The Shadow Surfer
Tux's lil' helper
Tux's lil' helper


Joined: 08 Jun 2002
Posts: 102
Location: Denmark

PostPosted: Sun Mar 02, 2003 8:00 pm    Post subject: Mysql - ERROR 1005 at line 27: Can't create table.... Reply with quote

I don't know if it's the rigth forume to ake a question like this, if not please correct me!

I have this SQL query, it gives this error:
Code:

ERROR 1005 at line 27: Can't create table './webshop/shop_products.frm' (errno:
150)

I can't see where the error lays!

I did some search on mysql, the closet I got to finde the error whas and old bug:

7.5.14.17 MySQL/InnoDB-3.23.50, April 23, 2002
Fixed a bug: in a CREATE TABLE statement the string 'foreign' followed by a non-space character confused the FOREIGN KEY parser and caused table creation to fail with errno 150.


But my query dosn't have an 'foreign' followed by a non-space character and I'm runnig the newest 3.23.55 (same error en 3.23.54x)

Code:

#
# Opretter databasen: webshop
#
CREATE DATABASE webshop;
use webshop;


#
#Tabel struktur for: shop_dealer
#
CREATE TABLE shop_dealer (
dealer_id INT NOT NULL auto_increment,
company_name VARCHAR (30) NOT NULL,
contact_person VARCHAR (128) NOT NULL,
address1 VARCHAR (128) NOT NULL,
address2 VARCHAR (128) NOT NULL,
zipcide INT (4) NOT NULL,
town VARCHAR (128) NOT NULL,
phone INT (11) NOT NULL,
cellphone INT (11) NOT NULL,
PRIMARY KEY (dealer_id)
) TYPE=INNODB;

#
#Tabel struktur for: shop_products
#
CREATE TABLE shop_products (
product_id INT NOT NULL auto_increment,
name VARCHAR (15) NOT NULL ,
descript TEXT NOT NULL ,
in_price MEDIUMINT (16) NOT NULL ,
out_price MEDIUMINT (16) NOT NULL ,
cat VARCHAR (10) NOT NULL ,
photo BLOB NOT NULL ,
sale ENUM ('Y','N') NOT NULL  default 'N',
store MEDIUMINT (16) NOT NULL ,
ordermore MEDIUMINT (16) NOT NULL ,
primary_dealer INT NOT NULL,
PRIMARY KEY (product_id) ,
FOREIGN KEY (primary_dealer) REFERENCES shop_dealer(dealer_id)
) TYPE=INNODB;
#
#Tabel struktur for: shop_customer
#
CREATE TABLE shop_customer (
customer_id  INT NOT NULL auto_increment,
f_name VARCHAR (128) NOT NULL,
l_name VARCHAR (128) NOT NULL,
address1 VARCHAR (128) NOT NULL,
address2 VARCHAR (128) NOT NULL,
zipcide INT (4) NOT NULL,
town VARCHAR (128) NOT NULL,
phone INT (11) NOT NULL,
cellphone INT (11) NOT NULL,
PRIMARY KEY (customer_id)
) TYPE=INNODB;


#
#Tabel struktur for: shop_basket
#
CREATE TABLE shop_basket(
basket_id INT NOT NULL auto_increment ,
session_id VARCHAR (32) NOT NULL ,
product_id INT NOT NULL ,
PRIMARY KEY (basket_id) ,
FOREIGN KEY (product_id) REFERENCES shop_products(product_id)
) TYPE=INNODB;


#
#Tabel struktur for: shop_orders
#
CREATE TABLE shop_orders (
order_id INT (12) NOT NULL auto_increment ,
product_id INT NOT NULL ,
customer_id INT NOT NULL ,
date INT (12) NOT NULL,
PRIMARY KEY (order_id) ,
FOREIGN KEY (product_id) REFERENCES shop_products(product_id) ,
FOREIGN KEY (customer_id) REFERENCES shop_customer(customer_id)
) TYPE=INNODB;
Back to top
View user's profile Send private message
The Shadow Surfer
Tux's lil' helper
Tux's lil' helper


Joined: 08 Jun 2002
Posts: 102
Location: Denmark

PostPosted: Mon Mar 03, 2003 8:05 pm    Post subject: Reply with quote

Fixed!!!

I didn't do an INDEX on the FOREIGN KEY

Code:

#
# Opretter databasen: webshop
#
CREATE DATABASE webshop;
use webshop;


#
#Tabel struktur for: shop_dealer
#
CREATE TABLE shop_dealer (
    dealer_id INT NOT NULL auto_increment,
    company_name VARCHAR (30) NOT NULL,
    contact_person VARCHAR (128) NOT NULL,
    address1 VARCHAR (128) NOT NULL,
    address2 VARCHAR (128) NOT NULL,
    zipcide INT (4) NOT NULL,
    town VARCHAR (128) NOT NULL,
    phone INT (11) NOT NULL,
    cellphone INT (11) NOT NULL,
        PRIMARY KEY (dealer_id)
) TYPE=INNODB;

#
#Tabel struktur for: shop_products
#
CREATE TABLE shop_products (
    product_id INT NOT NULL auto_increment,
    name VARCHAR (15) NOT NULL ,
    descript TEXT NOT NULL ,
    in_price MEDIUMINT (16) NOT NULL ,
    out_price MEDIUMINT (16) NOT NULL ,
    cat VARCHAR (10) NOT NULL ,
    photo BLOB NOT NULL ,
    sale ENUM ('Y','N') NOT NULL  default 'N',
    store MEDIUMINT (16) NOT NULL ,
    ordermore MEDIUMINT (16) NOT NULL ,
    primary_dealer INT NOT NULL,
        PRIMARY KEY (product_id) ,
        INDEX dealer_id_idx (primary_dealer),
        FOREIGN KEY (primary_dealer) REFERENCES shop_dealer(dealer_id)
) TYPE=INNODB;
#
#Tabel struktur for: shop_customer
#
CREATE TABLE shop_customer (
    customer_id  INT NOT NULL auto_increment,
    f_name VARCHAR (128) NOT NULL,
    l_name VARCHAR (128) NOT NULL,
    address1 VARCHAR (128) NOT NULL,
    address2 VARCHAR (128) NOT NULL,
    zipcide INT (4) NOT NULL,
    town VARCHAR (128) NOT NULL,
    phone INT (11) NOT NULL,
    cellphone INT (11) NOT NULL,
        PRIMARY KEY (customer_id)
) TYPE=INNODB;


#
#Tabel struktur for: shop_basket
#
CREATE TABLE shop_basket(
    basket_id INT NOT NULL auto_increment ,
    session_id VARCHAR (32) NOT NULL ,
    product_id INT NOT NULL ,
        PRIMARY KEY (basket_id) ,
        INDEX product_id_idx(product_id),
        FOREIGN KEY (product_id) REFERENCES shop_products(product_id)
) TYPE=INNODB;


#
#Tabel struktur for: shop_orders
#
CREATE TABLE shop_orders (
    order_id INT (12) NOT NULL auto_increment ,
    product_id INT NOT NULL ,
    customer_id INT NOT NULL ,
    date INT (12) NOT NULL,
        PRIMARY KEY (order_id) ,
        INDEX product_id_idx(product_id),
        FOREIGN KEY (product_id) REFERENCES shop_products(product_id) ,
        INDEX customer_id_idx(customer_id),
        FOREIGN KEY (customer_id) REFERENCES shop_customer(customer_id)
) TYPE=INNODB;
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Mon Mar 03, 2003 9:10 pm    Post subject: Reply with quote

Moved from Portage & Progrmming.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum