Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 27th, 2004, 12:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default Make an existing field auto_increment

I have a table that I got deleted. I remade the table and populated it by hand, but to add new data I need one of the fields to be an auto_increment field how do I set that field to auto_increment since it now has data in it that I need to keep those values.

describe MY_categories;
+-------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+----------------+
| cat_id | int(4) | | PRI | NULL | auto_increment |
| parent_id | int(4) | YES | | NULL | |

I need the cat_id to be made to auto_increment, but I do have numbers in that field allready (the ones I had to add by hand).
__________________
Mitch
 
Old April 6th, 2004, 04:08 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

ALTER TABLE table_name AUTO_INCREMENT = 60;

Just fill in the number for the last highest integer.

From the MySQL manual:
  http://www.mysql.com/doc/en/example-AUTO_INCREMENT.html

: )
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::





Similar Threads
Thread Thread Starter Forum Replies Last Post
Output existing value to new field Neal SQL Server 2000 5 March 12th, 2007 09:51 AM
SQL script auto_increment vickr1z MySQL 3 January 22nd, 2007 08:22 AM
how to make a query from an existing query raport SQL Language 3 November 13th, 2006 08:59 PM
Make user entered field an integer sswingle Classic ASP Basics 4 April 10th, 2006 10:09 PM
MySQL AUTO_INCREMENT field fcamilo Beginning PHP 1 August 21st, 2003 06:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.