Hi,

I have database table in mysql in that i want to remove all row from table.when i remove all row from table next auto index should start from one not the next one row.
like there are 50 records or rows in a table then i removed all the rows then after removing it should start from 1 not 51.

Bhaskar Bhatt Default Asked on March 8, 2016 in Database.
Add Comment
  • 1 Answer(s)

    As you wanted to remove all the from table in mysql.

    Three are two ways to remove all the from table:

      1. Remove All rows using , DELETE statement
      2. Remove All rows using , Truncate statement

    1.By using DELETE , it will remove all the rows from table but it will set auto_increment value to next number.
    Syntax,

    
     DELETE from table_name;
     

    2.By using Truncate :It will remove all the rows and set next auto_increment to 1.
    Logically,It drops table and recreate table;

    Syntax,

    
     TRUNCTATE table table_name;
     

    Bhaskar Monitor Answered on September 21, 2016.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.