A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearClear data in MySQL table with PHP? [duplicate] - page 1
User InfoPosts
Clear data in MySQL table with PHP? [duplicate]#1
This question already has an answer here:


Empty database in MySQL and PHP?

4 answers




How do I clear all the entries from just one table in MySQL with PHP?

posted date: 2009-04-07 06:20:00


Re: Clear data in MySQL table with PHP? [duplicate]#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-07 06:20:01


Re: Clear data in MySQL table with PHP? [duplicate]#3
TRUNCATE TABLE mytableBe careful with it though.

posted date: 2009-04-07 06:21:00


Re: Clear data in MySQL table with PHP? [duplicate]#4
TRUNCATE TABLE tablenameorDELETE FROM tablenameThe first one is usually the better choice, as DELETE FROM is slow on InnoDB.Actually, wasn(t this already answered in your other question?

posted date: 2009-04-07 06:24:00


Re: Clear data in MySQL table with PHP? [duplicate]#5
TRUNCATE TABLE table;is the SQL command. In PHP, you(d use:mysql_query((TRUNCATE TABLE table;();

posted date: 2009-04-07 06:26:00


Re: Clear data in MySQL table with PHP? [duplicate]#6
TRUNCATE TABLE `table`unless you need to preserve the current value of the AUTO_INCREMENT sequence, in which case you(d probably preferDELETE FROM `table`though if the time of the operation matters, saving the AUTO_INCREMENT value, truncating the table, and then restoring the value usingALTER TABLE `table` AUTO_INCREMENT = valuewill happen a lot faster.

posted date: 2009-04-07 06:46:00


Re: Clear data in MySQL table with PHP? [duplicate]#7
And from a requirement perspective, truncate will reset the indicies whereas delete won't.

posted date: 2009-04-07 06:48:00


Re: Clear data in MySQL table with PHP? [duplicate]#8
Actually I believe the MySQL optimizer carries out a TRUNCATE when you DELETE all rows.

posted date: 2009-04-07 11:36:00


Re: Clear data in MySQL table with PHP? [duplicate]#9
Don(t mean to sound rude but this is something that can be easily answered with a quick google search. You should do that before you ask a community. w3schools.com is a great website for learning all this stuff. Here is a link that is a great tutorial for php and mysql. http://www.w3schools.com/php/php_mysql_intro.asp

posted date: 2012-08-05 06:39:00


Re: Clear data in MySQL table with PHP? [duplicate]#10
MySQLI example where $con is the database connection variable and table name is: mytable.mysqli_query($con,(TRUNCATE TABLE mytable();

posted date: 2014-10-09 20:12:00


Re: Clear data in MySQL table with PHP? [duplicate]#11
TRUNCATE will blank your table and reset primary key DELETE will also make your table blank but it will not reset primary key.we can use for truncate TRUNCATE TABLE tablenamewe can use for deleteDELETE FROM tablenamewe can also give conditions as belowDELETE FROM tablename WHERE id=(xyz(

posted date: 2015-09-09 21:46:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.