SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key

Updated at 26-Apr-2022, By samar

SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key

Hello everyone, in this post we will look at how to solve "SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key" in programming.

I have got this error while migrating a migration file in Laravel to create a tiny integer column.
$table->tinyInteger('order_by', 4)->after('status')->nullable();  
  • Create tiny integer column in Laravel using migration

    //Change from
    $table->tinyInteger('order_by', 4)->after('status')->nullable();
    
    //To 
    $table->tinyInteger('order_by')->after('status')->nullable();
    

Back to code snippet queries related laravel