Search code examples
mysqldatatableintegersigned

In MySQL is there any difference when INT data type is explicitly stated to be UNSIGNED and when it is not?


In MySQL I can declare a table as -

CREATE TABLE table1 ( column1 INT );

I can also declare a table as -

CREATE TABLE table2 ( column2 INT SIGNED );

So is there any difference between the two tables or are they same?


Solution

  • Extracted from MySQL official documentation about Numeric type syntax:

    "Numeric data types that permit the UNSIGNED attribute also permit SIGNED. However, these data types are signed by default, so the SIGNED attribute has no effect."

    Therefore both columns in your example above have the same datatype of INT SIGNED. Unless you're defining one of it as UNSIGNED, then there's a difference.