mysqli truncate

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

mysqli truncate

Postby 12strings » 27. September 2014 20:19

I need to remove all records in a table and set the id to 1. can't figure out how? Thanks in advance.
After 5 minutes, no action, no error message, no chg to table.
I'm running PHP version 5.4.4

Code: Select all
$db = new mysqli("localhost","root","cookie","homedb");
if($db->query("ALTER TABLE calculator AUTO_INCREMENT = 1") == false) {
  throw new Exception("autoincrement reset failed: ".$db->error);
Posts: 28
Joined: 04. April 2013 17:56
Operating System: win 7 32 bit

Re: mysqli truncate

Postby Nobbie » 27. September 2014 21:30

Simple run a "Drop Table" and create a new table after. Truncate does not reset the primary key.
Posts: 10620
Joined: 09. March 2008 13:04

Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 4 guests