我尝试在Laravel 5.3项目中遵循3个代码,将新的十进制列添加到现有表中.但它每次都会给出同样的错误.
Schema::table('mileages', function (Blueprint $table) {
$table->addColumn('decimal', 'cost');
});
Run Code Online (Sandbox Code Playgroud)
和
Schema::table('mileages', function (Blueprint $table) {
$table->addColumn('decimal', 'cost', ['default'=>0]);
});
Run Code Online (Sandbox Code Playgroud)
和
Schema::table('mileages', function (Blueprint $table) {
$table->addColumn('decimal', 'cost', ['default'=>'0,0']);
});
Run Code Online (Sandbox Code Playgroud)
错误是:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near ' ) not null' at line 1 (SQL: alter table `mileages` add `cost` decimal (, ) …Run Code Online (Sandbox Code Playgroud)