Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc-sql

 
ahsan mir
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just started using jdbc after a long time so am not sure about the table creation syntax in mysql.I think it has something to do with indexing.

any help would be appreciated.
*********************************************
mysql> create table county ( countynumber integer not null auto_increment,
-> countyname varchar(32),
-> state varchar(32),
-> primary key(countynumber));
Query OK, 0 rows affected (0.38 sec)

mysql> create table voterregistration(
-> ssn integer not null,
-> firstname varchar(32) not null,
-> lastname varchar(32) not null,
-> countynumber integer not null,
-> primary key(ssn),
-> foreign key(countynumber) references county);
ERROR 1005 (HY000): Can't create table '.\jspexample\voterregistration.frm' (err
no: 150)
 
Martin Simons
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not to sound mean or demeaning, but try the forums at www.mysql.org
 
ahsan mir
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my mistake:-(

the following works:

*****************************************
ALTER TABLE county ADD INDEX(countynumber);

> create table voterregistration(
-> ssn integer not null,
-> firstname varchar(32) not null,
-> lastname varchar(32) not null,
-> countynumber integer not null,
-> primary key(ssn),
-> foreign key(countynumber) references county(countynumber))
-> ENGINE=InnoDB;
Query OK, 0 rows affected (0.11 sec)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic