Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel schema builder INT(11) on integer() and INT(10) on unsignedInteger()

Why does Laravel create the integer column as INT(11) and unsigned integer column as INT(10)?

$table->integer('integer'); // INT(11)
$table->unsignedInteger('unsignedInteger'); // INT(10) unsigned
$table->integer('integer_then_unsigned')->unsigned(); // INT(10) unsigned

Since the unsigned integers maximum value can be almost twice as large, shouldn't it rather be the other way around?

like image 931
Artur K. Avatar asked Aug 27 '14 12:08

Artur K.


2 Answers

Because of the minus sign when integer can be signed.

Unsigned integers will have 10 digits, and its display length is therefore - 10.

Signed integers will require a space for the minus sign, if it's negative. Therefore, on top of 10 digits, you need another one for the sign.

like image 194
N.B. Avatar answered Oct 09 '22 01:10

N.B.


It is because the minus sign in case your column is signed, which allows the field to have negative integers. You can have up to 10 digits when your field is unsigned.

like image 43
spetsnaz Avatar answered Oct 09 '22 01:10

spetsnaz