Solved

delete table and have auto increment primary key start back at 1

Posted on 2013-01-24
3
494 Views
Last Modified: 2013-01-24
mysql_query("drop table $table;");
mysql_query("create table $table like $oldtable;");


these php commands are not running
but these commands run in the mysql query editor


I want to do
delete from table
but I have an auto increment primary key

I want to delete table and have auto increment primary key start back at 1
0
Comment
Question by:rgb192
  • 2
3 Comments
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 38815146
Hi.

TRUNCATE the table instead of dropping it.
REFMAN: http://dev.mysql.com/doc/refman/5.0/en/truncate-table.html

Best regards and happy coding,

Kevin
0
 

Author Comment

by:rgb192
ID: 38816659
truncate table tablename worked in a mysql workbench query editor

but not with php

mysql_query("truncate table $table");
0
 

Author Closing Comment

by:rgb192
ID: 38816672
truncate works
 on php and mysql query editor
thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL Error 3 43
get the data all row not only one row php 4 62
updating the date data 12 30
Mysql Left Join Case 10 55
Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question