Page 1 of 1

creating a key in a table

Posted: Sun Mar 27, 2005 3:12 am
by pelegk2
i want to chamge a column that is defined as :
order_id int(8) unsinged notnull
and tried to do :
alter TABLE tblprodoreder add PRIMARY KEY (order_id)
but i get "duplicate entry '0' for key 1"
what to do?
and how do i define it as autoincementae too?
thnaks i nadvance
peleg

Posted: Sun Mar 27, 2005 10:49 am
by feyd
the key requires all values to be unique among the data in the field. So if you repeat a value, you'll get an error.

I don't remember the syntax for adding auto_increment, can't quite check it right now either.. Why not use phpMyAdmin (assuming you're using MySQL..) ?

the problem is that i have

Posted: Mon Mar 28, 2005 12:46 am
by pelegk2
already defined :
order_id int(8) default 0
and beaucse of that all the rws are 0 now
and maybe beacuse of that i cant do a key!
how can i fizx it?

Posted: Mon Mar 28, 2005 12:57 am
by feyd
fix the values. :?

how can i fix them?

Posted: Mon Mar 28, 2005 1:07 am
by pelegk2
to write a script that will un all over the rows and change the valued to a running numbers?

Posted: Mon Mar 28, 2005 1:10 am
by feyd
they need to be unique among their peers, so... something like that, yeah.