1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

(MySQL) Display width out of range?

Discussion in 'Off-Topic' started by Muqsit, Apr 25, 2017.

  1. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    According to this article, it should be alright.
    xs.PNG

    MySQL version
    zs.PNG
     
  2. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    According to the documentation a small unsigned int covers the range of 0-65535 which is more than enough to cover the maximum value a short (roughly 32000) can be (item id/meta).
    Code:
    CREATE TABLE quicksell(
    id INT AUTO_INCREMENT PRIMARY KEY,
    itemid SMALLINT UNSIGNED NOT NULL,
    itemdmg SMALLINT UNSIGNED DEFAULT 0,
    price SMALLINT(25000) UNSIGNED NOT NULL
    );
    
     
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    The number behind SMALLINT is approximately the number of digits of the SMALLINT (i.e. the display width). You don't need to add a number behind the type.
    Usually, you don't need to set this number at all.
    SMALLINT is always stored as 16 bits, and you can't set any range for it (except UNSIGNED), nor would it affect the performance etc.
    Reference: http://stackoverflow.com/a/4055587/3990767
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Thank you both, godspeed you.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.