[RESOLVED] What happens when using a 'tiny int' id data type in phpMyAdmin? Plz help!
Results 1 to 5 of 5

Thread: [RESOLVED] What happens when using a 'tiny int' id data type in phpMyAdmin? Plz help!

  1. #1
    Senior Member Paul help!'s Avatar
    Join Date
    Aug 2013
    Location
    Manchester, England.
    Posts
    249

    resolved [RESOLVED] What happens when using a 'tiny int' id data type in phpMyAdmin? Plz help!

    Hi guys.

    I am just curious about the limitations of different INT data types in phpMyAdmin.

    I use phpMyAdmin to store databases and tables.

    And obviously, when working within a table I will usually create an 'id' column and set it to an INT data type and 'auto increment'.

    The thing is, in the book I have been learning php from, the author set the 'id' field as a 'SMALL INT'.

    I have recently built a reviews application for a client of mine.... so his customers can leave testimonials on his website.

    And when someone leaves a review, it inserts a row inside a table on the database.

    And I have set an 'id' field and made it a 'SMALL INT' auto increment (inside this table I am refering to).


    What I want to know is,,, once this 'SMALL INT' data type reaches it's limit, what will happen???


    Will my clients application just simply stop working once a certain number of rows have been inserted?


    Paul.

  2. #2
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Contact Unit "Coping Mechanism"
    Posts
    22,518
    https://dev.mysql.com/doc/refman/5.7...-overflow.html

    From: https://dev.mysql.com/doc/refman/5.7...increment.html
    When the column reaches the upper limit of the data type, the next attempt to generate a sequence number fails.
    Last edited by Weedpacket; 07-17-2017 at 10:51 AM.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  3. #3
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,855
    My suggestion is to figure out what the maximum value might be (whether that is a best case or worst case?) and plan accordingly. Saving a few bytes on the disk and possibly a couple microseconds' worth of data transfer time may not be worth the hassle of a program crash in the future.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  4. #4
    Senior Member Paul help!'s Avatar
    Join Date
    Aug 2013
    Location
    Manchester, England.
    Posts
    249
    In that case.

    To avoid my code from failing to work correctly, I would probably be best choosing the standard INT data type,,, rather than SMALLINT,, or MEDIUM INT,,, etc.. ??

  5. #5
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,855
    Here's the max sizes, both for signed and unsigned integer types: https://dev.mysql.com/doc/refman/5.7...ger-types.html

    One table I use at work (with ~16 million rows) would actually overflow for the signed medium integer maximum, but would be okay with unsigned.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •