0

I understand int stores about 4 bytes and bigint stores about 8 bytes in MySQL

Since one can specify the length of each field in MySQL, Will an int(20) takeup the same space as a bigint(20)?

wolfgang
  • 7,281
  • 12
  • 44
  • 72
  • 2
    possible duplicate of [Types in MySQL: BigInt(20) vs Int(20) etcc](http://stackoverflow.com/questions/3135804/types-in-mysql-bigint20-vs-int20-etcc) – raina77ow Mar 01 '15 at 13:41
  • @raina77ow Yes, I could'nt find the question on a stackoverflow search, Thanks! – wolfgang Mar 01 '15 at 13:41
  • 1
    In short, there's no meaningful difference between `int(20)` and `int(10)`. There's a big difference between `INT` and `BIGINT`, however. Check [the manual](http://dev.mysql.com/doc/refman/5.1/en/numeric-type-attributes.html) for details. – raina77ow Mar 01 '15 at 13:41

1 Answers1

2

This is a bit long for a comment.

The number of bytes occupied by a value is determined by the type. You can see the list of numeric types and their sizes here.

In addition, MySQL supports "attributes" on numeric types. The (20) is a display width on output. The attributes are explained here.

So, for your example, the storage occupied by the fields is different because the types being used are different.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786