943,817 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1075
  • PHP RSS
Sep 6th, 2008
0

Mysql edit

Expand 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

Rakesh
Last edited by knrakesh; Sep 6th, 2008 at 8:37 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
knrakesh is offline Offline
35 posts
since Jul 2008
Sep 7th, 2008
0

Re: Mysql edit

Hi knrakesh,

Click to Expand / Collapse  Quote originally posted by knrakesh ...
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):
Quote ...
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
Reputation Points: 15
Solved Threads: 1
Newbie Poster
tgbyhn is offline Offline
8 posts
since Sep 2008
Sep 8th, 2008
0

Re: Mysql edit

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 ?
Reputation Points: 30
Solved Threads: 36
Posting Whiz
langsor is offline Offline
389 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: question about upload php files
Next Thread in PHP Forum Timeline: Error with db manage form





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC