Laravel學習:Schema Builder數據表字段類型

Command Description
$table->increments('id'); Incrementing ID to the table
$table->string('email'); VARCHAR equivalent column
$table->string('name', 100); VARCHAR equivalent with a length
$table->integer('votes'); INTEGER equivalent to the table
$table->float('amount'); FLOAT equivalent to the table
$table->decimal('amount', 5, 2); DECIMAL equivalent with a precision and scale
$table->boolean('confirmed'); BOOLEAN equivalent to the table
$table->date('created_at'); DATE equivalent to the table
$table->timestamp('added_on'); TIMESTAMP equivalent to the table
$table->timestamps(); Adds created_at and updated_at columns
$table->text('description'); TEXT equivalent to the table
$table->blob('data'); BLOB equivalent to the table
->nullable() Designate that the column allows NULL values
->default($value) Declare a default value for a column

Note: Laravel’s 「boolean」 type maps to a small integer column on all database systems.ui

相關文章
相關標籤/搜索