שאלה מטופשת...

yair24

Member
שאלה מטופשת...

בPHPMYADMIN מישהו יודע מה מסמן המספר שיש בסוגריים של INT? למשל בVARCHAR אם רשום:
VARCHAR(30)​
זה אומר שזה מחרוזת שמוגדרת 30 תוים אבל מה זה ככה:
INT(11)​
בהתחלה חשבתי שזה 11 ביטים אבל זה לא הגיוני ולא נכון. אז חשבתי אולי 11 ספרות למספר אבל במנואל מוגדר שINT המספר הכי גבוה בו הוא: 4294967295 שזה 10 ספרות אז כנראה ש11 זה גם לא מספר הספרות... מה זה המספר הזה? יאיר
 

yair24

Member
לא יכול להיות שלא יודעים...

אף אחד לא יודע את התשובה לשאלה?
 

N i X

New member
לא יכול להיות שלא חיפשת במנואל ;)

Another extension is supported by MySQL for optionally specifying the display width of an integer value in parentheses following the base keyword for the type (for example, INT(4)). This optional width specification is used to left-pad the display of values whose width is less than the width specified for the column, but does not constrain the range of values that can be stored in the column, nor the number of digits that will be displayed for values whose width exceeds that specified for the column. When used in conjunction with the optional extension attribute ZEROFILL, the default padding of spaces is replaced with zeroes. For example, for a column declared as INT(5) ZEROFILL, a value of 4 is retrieved as 00004. Note that if you store larger values than the display width in an integer column, you may experience problems when MySQL generates temporary tables for some complicated joins, as in these cases MySQL trusts that the data did fit into the original column width.​
MySQL manual
 

yair24

Member
תודה

לא שהבנתי מה עושים עם זה אבל תודה על ההפניה :) יאיר
 

XiroX

New member
זה קובע את "אורך" המספר שיתקבל

כלומר, כמה ספרות יהיו בו. כמו בדוגמה שנתנו, 4 ב init(6) יהיה 000004. לפחות ככה אני הבנתי את זה
 
למעלה