我正在Laravel 5上设置迁移,我想知道是否有关于每种列类型的默认长度的文档?他们是否遵循一些类似MySQL的约定?
例如: INTEGER、TEXT、MEDIUMTEXT、LONGTEXT
我说的是这些列类型:(http://laravel.com/docs/5.0/schema#adding-columns)
发布于 2015-04-04 03:52:55
以下是列类型的Laravel文档链接
http://laravel.com/api/5.0/Illuminate/Database/Schema/Blueprint.html
从文档中可以看出,默认的255是施加在string()和char()方法上的,如
http://laravel.com/api/5.0/Illuminate/Database/Schema/Blueprint.html#method_string
希望这能有所帮助!
发布于 2019-09-08 15:44:55
字符串类型
CHAR - 1 to 191 (删除尾随空格)
STRING - 1 to 16,300 (用户定义)
TEXT - 1 to 65,535
MEDIUMTEXT - 1 to 16,777,215
LONGTEXT - 1 to 4,294,967,295
整数类型
TINYINT - 0 to 255 (无符号)| -128 to 127 (有符号)
SMALLINT - 0 to 65,535 (无符号)| -32,768 to 32,767 (有符号)
MEDIUMINT - 0 to 16,777,215 (无符号)| -8,388,608 to 8,388,607 (有符号)
INT - 0 to 4,294,967,295 (无符号)| -2,147,483,648 to 2,147,483,647 (有符号)
BIGINT - 0 to 18,446,744,073,709,551,615 (无符号)| -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (有符号)
浮点类型
结构:([max decimal places], [max precision])
FLOAT - ([0-7], [0-23])
DOUBLE - ([0-14], [24-53])
十进制- ([0-65], [0-30])
注意: decimal存储我们以INT格式打印出来的精确值。如下例所示:
DOUBLE = DECIMAL = 2.65
//convert it to int
DOUBLE = 2
DECIMAL = 3查看laravel的所有列类型:documentation
https://stackoverflow.com/questions/29381815
复制相似问题