Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes MySql primary keys Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySql primary keys" Watch "MySql primary keys" New topic
Author

MySql primary keys

Mike Southgate
Ranch Hand

Joined: Jul 18, 2003
Posts: 183
Now, I know this isn't quite JDBC but...

I'm trying to create a table in MySql with 2 columns as the primary key. I tried this:
create table workout (
userId varchar(32) primary key,
workoutId mediumint primary key,
workoutDate date,
workoutType tinyint,
creationDate date,
lastUpdateDate timestamp,
lastUpdateUserId varchar(32) )
type=InnoDB;
but it didn't work...
Any suggestions?
ms


ms<br />SCJP, SCJD
Simon Havenith
Greenhorn

Joined: Mar 01, 2004
Posts: 4
How about :
create table workout (
userId varchar(32) ,
workoutId mediumint,
workoutDate date,
workoutType tinyint,
creationDate date,
lastUpdateDate timestamp,
lastUpdateUserId varchar(32),
PRIMARY KEY (userId,workoutId)) ;
Cheers
[ March 01, 2004: Message edited by: Simon Havenith ]
Mike Southgate
Ranch Hand

Joined: Jul 18, 2003
Posts: 183
thanks it worked (once I NOT NULL'ed the columns)
ms
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MySql primary keys
 
Similar Threads
How to model a relation where a column has to refer two columns in different tables?
Hibernate: Found two representations of same collection
sequence generator with mysql
Exception in Deleting Parent and Child entity
jdbc-sql