sql foreign keys

Posted by Paul Est on Stack Overflow See other posts from Stack Overflow or by Paul Est
Published on 2012-04-11T22:57:47Z Indexed on 2012/04/11 23:28 UTC
Read the original article Hit count: 347

I was create tables with the syntax in phpmyadmin:

DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS info;

CREATE TABLE users (
  user_id int unsigned NOT NULL auto_increment,
  email varchar(100) NOT NULL default '',
  pwd varchar(32) NOT NULL default '',
  isAdmin int(1) unsigned NOT NULL,
  PRIMARY KEY  (user_id)
) TYPE=INNODB;

CREATE TABLE info (
  info_id int unsigned NOT NULL auto_increment,
  first_name varchar(100) NOT NULL default '',
  last_name varchar(100) NOT NULL default '',
  address varchar(300) NOT NULL default '',
  zipcode varchar(100) NOT NULL default '',
  personal_phone varchar(100) NOT NULL default '',
  mobilephone varchar(100) NOT NULL default '',
  faxe varchar(100) NOT NULL default '',
  email2 varchar(100) NOT NULL default '',
  country varchar(100) NOT NULL default '',
  sex varchar(1) NOT NULL default '',
  birth varchar(1) NOT NULL default '',

  email varchar(100) NOT NULL default '',
  PRIMARY KEY  (info_id),
  FOREIGN KEY (email) REFERENCES users(email) ON UPDATE CASCADE ON DELETE CASCADE
) TYPE=INNODB;

But shows the error "#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=INNODB' at line 11 "

If i remove the TYPE=INNODB in the end of create the tables, it will show the error "#1005 - Can't create table 'curriculo.info' (errno: 150) ".

© Stack Overflow or respective owner

Related posts about sql

Related posts about table