doubledee Posted March 17, 2012 Share Posted March 17, 2012 How hard is it to change the data-type for your Primary Key if you outgrow it? I am creating an error table and was going to use MediumInt since I figure that if I log more than 16 million Errors then I either have code issues or a honking big site?! If I ever need to upgrade to Int would it be a big deal? Thanks, Debbie P.S. Why do I have to set a Length for the data-type like this MediumInt( 8 ) in phpMyAdmin?? I thought all MediumInt's were 8 characters wide? Quote Link to comment Share on other sites More sharing options...
cpd Posted March 17, 2012 Share Posted March 17, 2012 Upgrading isnt an issue at all as your only extending the amount of possibilities available. At byte level your literally adding more bytes, that's all. All the values in a mediumint type are available in an int type. Regarding the length, there will be a maximum value which can be set in a mediumint type and it will be X characters long. You can shorten the maximum length by setting a value but mediumint will have a limit itself, can't remember what the limits of any of the integers types are at the minute but you can look it up. Quote Link to comment Share on other sites More sharing options...
kicken Posted March 17, 2012 Share Posted March 17, 2012 I usually just start out all my ID's with INT UNSIGNED which allows up to 2 billion. Chances are no table in anything I do will ever hit that, but if by some miracle one did the type could just be upped to bigint without much trouble. P.S. Why do I have to set a Length for the data-type like this MediumInt( 8 ) in phpMyAdmin?? I don't really know about how phpMyAdmin works, but for numeric types the length parameter does not affect how much space is used or how many digits you can store. It's used only for display purposes when you SELECT that number, and doesn't really do much unless you use the ZEROFILL option to pad zeros. Quote Link to comment Share on other sites More sharing options...
doubledee Posted March 17, 2012 Author Share Posted March 17, 2012 P.S. Why do I have to set a Length for the data-type like this MediumInt( 8 ) in phpMyAdmin?? I don't really know about how phpMyAdmin works, but for numeric types the length parameter does not affect how much space is used or how many digits you can store. It's used only for display purposes when you SELECT that number, and doesn't really do much unless you use the ZEROFILL option to pad zeros. Oh, okay. That makes sense with the ZeroFIll. Thanks! Debbie Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.