【问题标题】:How to maximize the row size in laravel | mysql如何在 laravel 中最大化行大小 | mysql
【发布时间】:2021-08-22 10:50:46
【问题描述】:

我想最大化行描述的大小。我已经将大小设置为 10240,但仍然显示错误。由于要保存大量数据,如何在此列中存储数据

 public function up()
{
    Schema::create('final_news', function (Blueprint $table) {
        $table->id();
        $table->integer('id_newspaper');
        $table->string('heading');
        $table->string('description', 10240);
        $table->timestamps();
    });
}

我得到的错误

 SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'description' at row 1 (SQL: insert into `final_news` (`id_newspaper`, `heading`, `d

escription, updated_at, created_at`)

【问题讨论】:

标签: mysql laravel database-design migration


【解决方案1】:

如果字符串很长,你可以使用longtext

  $table->longText('description')

longText 方法创建一个 LONGTEXT 等效列:

参考:https://laravel.com/docs/8.x/migrations#column-method-longText

【讨论】:

  • MySQL 的 LONGTEXT 的大小限制为 4GB。
  • @RickJames.感谢您让我们知道
猜你喜欢
  • 2015-06-22
  • 2012-05-03
  • 2016-09-22
  • 2021-04-11
  • 1970-01-01
  • 2014-01-02
  • 1970-01-01
  • 1970-01-01
  • 2017-10-31
相关资源
最近更新 更多