badinfluence
Sep 7 2005, 09:54 PM
| | hi, Can we reset the id auto increment in the mysql database using by phpMyadmin? let's say the shoutbox. the id #number table.. somehow i deleted some rows.. and i wanted to re-order/reset the id number acendingly in order rather than skip out.. thks
|
Reply
SystemWisdom
Sep 7 2005, 11:44 PM
I don't think you can do that using phpMyAdmin, or even SQL for that matter, but you could write a PHP script to do that for ya... Make a query like: Select ID from <table> order by ID then use a while/for loop to iterate through the results, and update each row with a new number for the ID.. you could use a PHP variable to track the current ID number, and increment it with each loop... Update <table> set ID=??? Should work.. Although I have never tried manually updating an auto_increment field.. come to think of it, it seems pointless to adjust it, since it is dealt with internally anyway, and the actual value should never affect your script... If that doesn't work, and you still need to sort them, try adding another field to the DB table, like a sort-order field..
Reply
tigen28
Sep 9 2005, 07:31 AM
Please be warn that this is the manual-intensive-labor way, but no thinking require. If you want to change any field in the table and do not mind changing only 1 field at a time, you can always go to php admin. Then, select your database. Next, click on the "table" you want to modify. Last find the field and click edit; so basicially, click on field of a time and edit. Hopefully, you don't have much entries in that table; otherwise, I highly unrecommend this route. Well, hope it helps.
Reply
badinfluence
Sep 14 2005, 02:51 AM
QUOTE(SystemWisdom @ Sep 8 2005, 08:44 AM) I don't think you can do that using phpMyAdmin, or even SQL for that matter, but you could write a PHP script to do that for ya... Make a query like: Select ID from <table> order by ID then use a while/for loop to iterate through the results, and update each row with a new number for the ID.. you could use a PHP variable to track the current ID number, and increment it with each loop... Update <table> set ID=??? yes, System that's perfect and exactly true. Thanks for that trick. Indeed a littol risky humm.. phpMyAdmin should do that function by default. See whether i can request the feature about that on their sourceforge site. this is the old and null way  backup and re-construct Thanks System and tigen for discussing this,
Reply
beeseven
Sep 22 2005, 11:02 PM
I asked about this a while ago. A quick and easy way to set the next ID is this: CODE ALTER TABLE [tablename] AUTO_INCREMENT = [number] where [tablename] is the name of the table and [number] is the next ID. I'm not sure of a quick way to change other, existing IDs, though.
Reply
p_a
Sep 24 2005, 10:41 AM
It would be better not to do reorder of ID fields anyway. I do not want even to show them in my forms, grids. Maybe the new numbered field would be the best way to solve it. Why shoud everybody avoid changing ID fields? Simply because of possibility of having relations in database between tables. ID fields sometimes have their main role in relations and playing games with them will make a mess. I would never do it.
Reply
csmith
Sep 25 2005, 06:24 AM
This is a pretty primitive solution, but after you delete the rows which you wish to remove from the table, you could export the remaining rows into either a .csv file. In this subsequent excel file you could remove the first column which contains the id, save this file, and then re-import this back into your database table (you should click on the option of over-writing rows in this table which have the same id/primary key value as a row in the excel file), or re-import into a new table. The ids will be automatically re-set without any numbers skipped - it should not take too long, plus you should not lose any data in the process
Reply
sobhan
Oct 2 2005, 02:36 PM
I don't think you can reset, you can only change value in phpMyAdmin.
Reply
najib
May 10 2006, 04:18 AM
I know it's a zombie post, but I thought I'd give my part nonetheless. CODE ALTER TABLE `tablenamegoeshere` AUTO_INCREMENT =0
The above will reset the auto_increment to the lowest value. So everytime an entry is removed, drop any remaing ID's that are larger than the current entry by one, then query the database with the exact line above and you wont have any problems. Sweet!
Reply
iGuest
May 13 2008, 08:04 AM
ALTER TABLE `tablenamegoeshere` AUTO_INCREMENT =0
Can Reset The Id Auto Increment?
Replying to najibIt's not a zombie post! Thanks! Saved a lot of time! :)
Reply
Recent Queries:--
phpmyadmin change default autoincrement - 1.21 hr back. (1)
-
reset autoincrement - 1.42 hr back. (1)
-
sql id reset - 2.15 hr back. (1)
-
mysql primary id auto increment skips - 2.21 hr back. (1)
-
phpmyadmin auto_increment reset - 5.34 hr back. (1)
-
how to reset auto incremet - 6.46 hr back. (1)
-
reset autoincrement column sql 2005 - 7.19 hr back. (1)
-
phpmyadmin auto increment zero - 8.71 hr back. (1)
-
auto_increment resetten - 10.73 hr back. (1)
-
mysql drop autoincrement counter - 10.92 hr back. (1)
-
phpmyadmin auto increment id reset - 11.33 hr back. (1)
-
auto_increment field out of order - 12.25 hr back. (1)
-
phpmyadmin reset row id - 12.74 hr back. (1)
-
phpmyadmin auto_increment - 15.96 hr back. (1)
Similar Topics
Keywords : reset, id, auto, increment, phpmyadmin
- Delete Problem With Id
Id as auto_increment, and identifier for a row (4)
Phpmyadmin Login Problem!
(1) I have easyphp. But i can not log when i go to phpmyadmin. I directly enter the page. But i think i
should normally have to log in before enter that page. What should i do to configure the access to
phpmyadmin? Thank for help....
Auto Pruning An Sql Database With Php
How can i do this? (4) Hey all. Now i have a DB, an SQL DB, and i need to auto prune the data there to delete rows lder
than a certain time, lets say 2 months for now, the question is how do i do this? The obvious thing
is just to add a field which is the numerical representation of the month when the data is entered
and every time the DB is accessed it will check this number against the current month,in a numerical
format, and if the difference is two or greater that row is deleted, so if the month is January, it
would be O1 and if the current month is march then it would be O3 and the diff....
Error Importing Sql Query Via Php
Works in PHPmyAdmin (6) CODE function sql() { $fp =
fopen("sql.sql","r"); $sql =
fread($fp,filesize("sql.sql")); fclose($fp);
return $sql; } Thats $this->sql and here is the other source CODE
function insert_sql() { if($_GET['insert']) {
$template = new template; $db = new db;
$db->connect(); $query = $this->sql(); ....
Phpmyadmin And Php And Mysql
tutorial (0) hi i think phpmyadmin is nice script (3rdparti) to learn php and mysql , you can add database and
then make tabel with rows and columns then you can customise (search , show rows , show columns ,
add rows , delete rows) tabel in phpmyadmin when you are customise phpmyadmin , this script show you
php code . you can use this code for browse in database . for example : showing tabel : CODE
SELECT * FROM `tabelname` LIMIT 0 , 30 searching : CODE SELECT `columns`
FROM `tabel` LIMIT 0 , 30 you can use with while loop showing Ascending....
Help Installing Phpmyadmin ..
(2) i've installed php and mysql to my computer and i want to install PhpMyAdmin , (i have apache) ,
i tried to find how to confure it , and it says Create the file config.inc.php in the main
(top-level) directory , i dont know how to create that file..can some one tell me how i can confure
that config file ?? and how i can run php in safe mode ?....
Requesting Auto Generating Id Tag In Php Code
Php Coding (2) Hello...I'm designing a website in PHP where ppl can submit their links for "cool sites".
Anyway, when somebody submit's a link to a website for example "http://www.google.com" it
creates an id such as "index.php?id=1134411593". I dont want the links to be converted into
id's. I want it to remain as "http://www.google.com". I have the following coding on
( echo " ). I'm a novice. Please Help!!!!
Thanks... Plus I also want to add the date on when the link was submitted. Please follow our foru....
Suppressing Mysql Error In Php
How to suppress auto generated mysql err (4) I am testing my website on my local machine. It is still in development stage and I am using
php/mysql. If there is a mysql connection error, I am checking for the connection variable and
displaying a proper error message. But even before it displays my error message, it displays an
error message on browser thrown by mysql (MySQL Connection Failed: Access denied for user). Can I
suppress this message and display only my message?....
Adding Users To Databases Using Phpmyadmin
(2) I am running my own apache server with PHP and MySQL, with phpMyAdmin on my own computer, to test
things locally. I know how to create databases and how to create users, but how can I add a user to
a database?....
Increment A Mysql Column
how to increment a MySQL column one unit (6) Hi, I have a column in a MySQL table which contains a counter of the views of the object described
by this table. I would like to increment this value by one everytime the object is viewed. Obviously
came into my mind the possibility of retrieving the value of this field, store it in a variable
increment this value by one and perform an UPDATE query again with this new value. My question is if
there is a MySQL option to update the field with its actual value plus an unit increment. I hope you
understand the issue.....
About Set Permisstions....
auto set it, how? (4) I have some problem about set permissions by automatic.. for example... I created txt file with
php... but when my file was added to server(trap17), it always set to 644 and i want to set it to
666 . Anybody help me... PLEASE /biggrin.gif' border='0' style='vertical-align:middle'
alt='biggrin.gif' /> ....
Looking for reset, id, auto, increment, phpmyadmin
|
|
Searching Video's for reset, id, auto, increment, phpmyadmin
|
advertisement
|
|