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

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
LVL 1
rgb192Asked:
Who is Participating?
 
Kevin CrossConnect With a Mentor Chief Technology OfficerCommented:
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
 
rgb192Author Commented:
truncate table tablename worked in a mysql workbench query editor

but not with php

mysql_query("truncate table $table");
0
 
rgb192Author Commented:
truncate works
 on php and mysql query editor
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.