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

Created at 25-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

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.