| Morgan Tocker ( @ 2007-12-17 22:12:00 |
| Entry tags: | mysql, php |
Just to confuse you...
Take a look at these two numbers:
CREATE TABLE my_table (
number_1 BIGINT(4),
number_2 INT (10)
);
Which one do you think takes up less space? The answer is that BIGINT always takes 8 bytes and that INT always takes 4 bytes. The value in the parenthesis has nothing to do with storage. The only use I am aware of that it has, is with the ZEROFILL feature (which I never use):
mysql> CREATE TABLE a (a INT(5) ZEROFILL);
Query OK, 0 rows affected (0.16 sec)
mysql> INSERT INTO a VALUES (1);
Query OK, 1 row affected (0.03 sec)
mysql> SELECT * FROM a;
+-------+
| a |
+-------+
| 00001 |
+-------+
1 row in set (0.00 sec)
It seems that there are a lot of open source packages with INT(4) (or similar). If you only need 4 digits, you probably want a SMALLINT ;)