2
我在Laravel 5.3項目中嘗試了以下3個代碼以將新的小數列添加到現有表中。但每次都會出現相同的錯誤。如何將小數點列添加到Laravel 5.3遷移中的現有表中
Schema::table('mileages', function (Blueprint $table) {
$table->addColumn('decimal', 'cost');
});
和
Schema::table('mileages', function (Blueprint $table) {
$table->addColumn('decimal', 'cost', ['default'=>0]);
});
和
Schema::table('mileages', function (Blueprint $table) {
$table->addColumn('decimal', 'cost', ['default'=>'0,0']);
});
錯誤是:
[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 (,) not null)
我這麼想嗎?
是的,它的工作。謝謝!。還有'$ table-> addColumn('decimal','cost',['default'=> 0,'total'=> 8,'places'=> 2]);'正在工作。 – Eranda