Two Primary Keys

2010-06-29 Thread Victor Subervi
Hi; I have the following: create table pics ( picture_id int auto_increment primary key, product_sku int not null primary key, picture_num int not null, picture_desc varchar(100), picture_data longblob ); which doesn't work I need to auto_increment and declare primary key on two

Re: Two Primary Keys

2010-06-29 Thread Jo�o C�ndido de Souza Neto
As far as I know, if you have an auto_increment primary key, you cant have any other field in its primary key. João Cândido. Victor Subervi victorsube...@gmail.com escreveu na mensagem news:aanlktikzksmbx5hue0x_q3hx_68gicndghpkjdrna...@mail.gmail.com... Hi; I have the following: create

Re: Two Primary Keys

2010-06-29 Thread Victor Subervi
to wondering, what is the purpose of having two primary keys? TIA, V

Re: Two Primary Keys

2010-06-29 Thread Jo�o C�ndido de Souza Neto
to wondering, what is the purpose of having two primary keys? TIA, V -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org

Re: Two Primary Keys

2010-06-29 Thread petya
If you use innodb, primary key lookups are far faster than secondary indexes. Peter On 06/29/2010 03:34 PM, João Cândido de Souza Neto wrote: I think the real question is: What´s the purpose of any other field in my primary key if the first one is an auto_increment and will never repeat?

Re: Two Primary Keys

2010-06-29 Thread Shawn Green (MySQL)
On 6/29/2010 9:24 AM, Victor Subervi wrote: Hi; I have the following: create table pics ( picture_id int auto_increment primary key, product_sku int not null primary key, picture_num int not null, picture_desc varchar(100), picture_data longblob ); which doesn't work I need to

Re: Two Primary Keys

2010-06-29 Thread Jo�o C�ndido de Souza Neto
I think the best, or may be the right way is to use picture_id as primary key and a unique index to product_sku. -- João Cândido de Souza Neto Victor Subervi victorsube...@gmail.com escreveu na mensagem news:aanlktikzksmbx5hue0x_q3hx_68gicndghpkjdrna...@mail.gmail.com... Hi; I have the

Re: Two Primary Keys

2010-06-29 Thread Victor Subervi
2010/6/29 João Cândido de Souza Neto j...@consultorweb.cnt.br I think the best, or may be the right way is to use picture_id as primary key and a unique index to product_sku. Yes, sounds good. So the purpose, then, is to speed lookups on fields commonly accessed. I'd forgotten that. Thanks, V

Re: Two Primary Keys

2010-06-29 Thread Dušan Pavlica
. Makes sense. Actually, I was just copying what someone else gave me and adding the auto_increment, then I got to wondering, what is the purpose of having two primary keys? TIA, V -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http

Re: Two Primary Keys

2010-06-29 Thread petya
You were talking about multiple fields in the primary key, not multiple primary keys. On 06/29/2010 03:51 PM, Johan De Meersman wrote: Correct, but you still can't have more than one primary key. Kind of defeats the idea of it being primary, really. On Tue, Jun 29, 2010 at 3:36 PM, petya

RE: Two Primary Keys

2010-06-29 Thread Steven Staples
on, where I've done this, but done it in code, rather than in mysql. Steven Staples -Original Message- From: Dušan Pavlica [mailto:pavl...@unidataz.cz] Sent: June 29, 2010 11:26 AM To: Victor Subervi Cc: mysql@lists.mysql.com Subject: Re: Two Primary Keys Hi, try

Re: Two Primary Keys

2010-06-29 Thread Kyong Kim
This isn't true for innodb. I think the only requirement is that you need to have a unique index on the auto increment column. We created a composite primary key + auto_increment to take advantage of clustering by primary key while satisfying unique constraint for the primary key. It worked out