• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

jdbc-sql

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic