How on Earth are you supposed to define a secondary key in a mysql table. For instance, when creating a table, what would the syntax be? I can't define two columns as "PRIMARY KEY"- that's an error.
Can anyone help me out here?? Thanks in advance...
Yes, only one column can be the primary key. But then that makes metaphoric sense -- how can more than one of something be the primary thing? Other columns can be indeces, too, though.
When you create the table, you can use the INDEX keyword to define an index:
create table foo (
id int unsigned not null auto_increment primary key,
foo varchar(10) not null,
bar int unsigned not null default(3),
index by_verb (verb));
Yeah, that's I was looking to do- have two columns that add up to a primary key...
In this case, it's the ALBUM id and the TRACK #... does that make sense? The albumID is a foreign key, and for each album there should only be one instance of each track, and that's where the trackNum column comes in...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.