Mysql edit

Reply

Join Date: Jul 2008
Posts: 32
Reputation: knrakesh is an unknown quantity at this point 
Solved Threads: 0
knrakesh's Avatar
knrakesh knrakesh is offline Offline
Light Poster

Mysql edit

 
0
  #1
Sep 6th, 2008
Hello friends,
i copied a table from other database and using in other database, when iam using the same table in other database the primary key in the table is just auto increamenting from the past table only.

i want it to start from 0

Rakesh
Last edited by knrakesh; Sep 6th, 2008 at 8:37 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 8
Reputation: tgbyhn is an unknown quantity at this point 
Solved Threads: 1
tgbyhn tgbyhn is offline Offline
Newbie Poster

Re: Mysql edit

 
0
  #2
Sep 7th, 2008
Hi knrakesh,

Originally Posted by knrakesh View Post
Hello friends,
i copied a table from other database and using in other database, when iam using the same table in other database the primary key in the table is just auto increamenting from the past table only.

i want it to start from 0
I don't think it can be done - easily at least (quote taken from http://dev.mysql.com/doc/refman/5.0/...-sql-mode.html):
NO_AUTO_VALUE_ON_ZERO

NO_AUTO_VALUE_ON_ZERO affects handling of AUTO_INCREMENT columns. Normally, you generate the next sequence number for the column by inserting either NULL or 0 into it. NO_AUTO_VALUE_ON_ZERO suppresses this behavior for 0 so that only NULL generates the next sequence number.

This mode can be useful if 0 has been stored in a table's AUTO_INCREMENT column. (Storing 0 is not a recommended practice, by the way.) For example, if you dump the table with mysqldump and then reload it, MySQL normally generates new sequence numbers when it encounters the 0 values, resulting in a table with contents different from the one that was dumped. Enabling NO_AUTO_VALUE_ON_ZERO before reloading the dump file solves this problem. mysqldump now automatically includes in its output a statement that enables NO_AUTO_VALUE_ON_ZERO, to avoid this problem.
Adnan
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 381
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 33
langsor langsor is offline Offline
Posting Whiz

Re: Mysql edit

 
0
  #3
Sep 8th, 2008
Did you copy the table structure or copy the table and all of its records too?

Because if you copied the records, you are not going to get a new key-sequence with existing records.

Copy the table structure only if you want to start over with new records.

Or I'm not understanding your problem clearly ?
Google is the answer to all of your questions -- the trick is knowing what question to ask in your specific predicament.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 925 | Replies: 2
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC