在“模式”构建器中更改列长度? [英] Alter column length in Schema builder?
本文介绍了在“模式”构建器中更改列长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个字段,我需要增加字符限制。我通过阅读文档,我惊讶地发现没有选择它。有可能做吗?如果没有,我该如何解决这个问题?
我可以删除列,重新创建它与正确的属性,但我不想松动任何数据库中的数据。
解决方案
使用原始查询:
/ **
*更改数据库。
*
* @return void
* /
public function up()
{
DB :: query('alter table MYTABLE modify MYCOLUMN varchar new-length)');
}
/ **
*将更改还原到数据库。
*
* @return void
* /
public function down()
{
DB :: query('alter table MYTABLE modify MYCOLUMN varchar old-length)');
}
替换 MYTABLE
MYCOLUMN
, new-length
和 old-length
/ p>
I have two fields i need to increment the character limit on. I're read through the documentation and to my surprise i found no option for it. Is it possible to do? If not, how should i go about solving this?
I could drop the column and re-create it with the correct properties, but i don't want to loose any data in the database.
解决方案
Use Raw Queries:
/**
* Make changes to the database.
*
* @return void
*/
public function up()
{
DB::query('alter table MYTABLE modify MYCOLUMN varchar(new-length)');
}
/**
* Revert the changes to the database.
*
* @return void
*/
public function down()
{
DB::query('alter table MYTABLE modify MYCOLUMN varchar(old-length)');
}
Replace MYTABLE
, MYCOLUMN
, new-length
and old-length
.
这篇关于在“模式”构建器中更改列长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文