Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

MySQL in HP-UX, how to populate an INT Field with ROWNUM/RECORDID Values?

SOLVED
Go to solution
Alzhy
Honored Contributor

MySQL in HP-UX, how to populate an INT Field with ROWNUM/RECORDID Values?

I added a INT column named KNBO to an existing populated TABLE. I want to set the value/contents of the filed KBNO to be the record number or rowid.

How do I?


Many thanks!
Hakuna Matata.
2 REPLIES
Laurent Laperrousaz
Regular Advisor
Solution

Re: MySQL in HP-UX, how to populate an INT Field with ROWNUM/RECORDID Values?

to add a field as a rownum, it just has to be auto_increment in the definition. So change your field definition

ALTER TABLE `TABLE` CHANGE `KNBO ` INT NOT NULL AUTO_INCREMENT PRIMARY KEY

That's it!

The field has to be the primary key

Hope this helps!
Jean-Luc Oudart
Honored Contributor

Re: MySQL in HP-UX, how to populate an INT Field with ROWNUM/RECORDID Values?

Nelson,

see example at :
http://dev.mysql.com/doc/mysql/en/example-auto-increment.html

Regards
Jean-Luc
fiat lux