1
Peekay
MySQL UNSIGNED - Should I use this?
  • 2006/12/2 22:28

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Tinkering with MySQL and wondered if anyone can advise me on this.

If I want to store the number 200, is it best to use:

a) TINYINT(4) UNSIGNED (which gives me 0 - 255)

or

b) SMALLINT(4) which allows for -32768 to 32767.

I read several places on the MySQL site that 'unsigned' is 'non-standard' so I wondered if it's worth bothering with for the amount of space saved. I also need to perform some 'sum' calculations at some point so I want to use the right data type.

Any tips would be apreciated
A thread is for life. Not just for Christmas.

2
Without
Re: MySQL UNSIGNED - Should I use this?
  • 2007/1/1 22:30

  • Without

  • Just popping in

  • Posts: 1

  • Since: 2007/1/1 2


I always use UNSIGNED in mySQL, but if you want use other database like postgreSQL, you can use SMALLINT.
SMALLINT takes 4 bytes, TINYINT takes 2 bytes.
When you use TINYINT you save 2 bytes per record.

3
Peekay
Re: MySQL UNSIGNED - Should I use this?
  • 2007/1/2 1:51

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Thx Without.

It does indeed seem a sensible thing to do to optimise the DB. I get the impression this only becomes an issue if you transfer to another DB system that doesn't support it - which isn't going to happen in my case.

Welcome to Xoops.org BTW.
A thread is for life. Not just for Christmas.

Login

Who's Online

384 user(s) are online (320 user(s) are browsing Support Forums)


Members: 0


Guests: 384


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits