我想知道如果我將INT值設爲8,是否意味着我只能從1到99999999或從1到4294967295 UNSIGNED?MySQL INT含義
回答
的文件似乎瞭解這個非常清楚:
數字類型屬性
MySQL支持用於可選地指定整數數據類型的括號中的顯示 寬度base關鍵字以下的延伸該類型爲 。例如,INT(4)指定一個INT,其顯示寬度爲四位數字。這個可選的顯示寬度可以被 應用程序用來顯示寬度小於爲該列指定的寬度的整數值,方法是用空格填充它們。 (即 是,該寬度是存在於與返回結果集的元數據。 無論是使用或不使用要由應用程序。)
顯示寬度不限制,可以是存儲 值的範圍在列中。它也不會阻止比顯示寬度的列 正確顯示更寬的值。例如,指定爲SMALLINT(3)的列 的常用SMALLINT範圍爲-32768至 32767,且三位數所允許的範圍之外的值爲 ,使用三位以上的數字完整顯示。
看看mysql documentation。它讓你知道所有數據類型的細節。最大值爲4294967295(無符號)
因此,在INT的值字段中,我必須將其設置爲4294967295? – Warface
您必須明確選擇unsigned,否則默認情況下它是有符號整數,因此您的值也可以是負數。並查看Tom Squires提供的鏈接文檔。
BTW看我找到了什麼 - > * HTTP://help.scibit.com/mascon/masconMySQL_Field_Types.html*
Type
Use for
Size
TINYINT
A very small integer
The signed range is –128 to 127. The unsigned range is 0 to 255.
SMALLINT
A small integer
The signed range is –32768 to 32767. The unsigned range is 0 to 65535
MEDIUMINT
A medium-size integer
The signed range is –8388608 to 8388607. The unsigned range is 0 to 16777215
INT or INTEGER
A normal-size integer
The signed range is –2147483648 to 2147483647. The unsigned range is 0 to 4294967295
BIGINT
A large integer
The signed range is –9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615
FLOAT
A small (single-precision) floating-point number. Cannot be unsigned
Ranges are –3.402823466E+38 to –1.175494351E-38, 0 and 1.175494351E-38 to 3.402823466E+38. If the number of Decimals is not set or <= 24 it is a single-precision floating point number
DOUBLE,
DOUBLE PRECISION,
REAL
A normal-size (double-precision) floating-point number. Cannot be unsigned
Ranges are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0 and 2.2250738585072014E-308 to 1.7976931348623157E+308. If the number of Decimals is not set or 25 <= Decimals <= 53 stands for a double-precision floating point number
DECIMAL,
NUMERIC
An unpacked floating-point number. Cannot be unsigned
Behaves like a CHAR column: 「unpacked」 means the number is stored as a string, using one character for each digit of the value. The decimal point, and, for negative numbers, the ‘-‘ sign is not counted in Length. If Decimals is 0, values will have no decimal point or fractional part. The maximum range of DECIMAL values is the same as for DOUBLE, but the actual range for a given DECIMAL column may be constrained by the choice of Length and Decimals. If Decimals is left out it’s set to 0. If Length is left out it’s set to 10. Note that in MySQL 3.22 the Length includes the sign and the decimal point
DATE
A date
The supported range is ‘1000-01-01’ to ‘9999-12-31’. MySQL displays DATE values in ‘YYYY-MM-DD’ format
DATETIME
A date and time combination
The supported range is ‘1000-01-01 00:00:00’ to ‘9999-12-31 23:59:59’. MySQL displays DATETIME values in ‘YYYY-MM-DD HH:MM:SS’ format
TIMESTAMP
A timestamp
The range is ‘1970-01-01 00:00:00’ to sometime in the year 2037. MySQL displays TIMESTAMP values in YYYYMMDDHHMMSS, YYMMDDHHMMSS, YYYYMMDD or YYMMDD format, depending on whether M is 14 (or missing), 12, 8 or 6, but allows you to assign values to TIMESTAMP columns using either strings or numbers. A TIMESTAMP column is useful for recording the date and time of an INSERT or UPDATE operation because it is automatically set to the date and time of the most recent operation if you don’t give it a value yourself
TIME
A time
The range is ‘-838:59:59’ to ‘838:59:59’. MySQL displays TIME values in ‘HH:MM:SS’ format, but allows you to assign values to TIME columns using either strings or numbers
YEAR
A year in 2- or 4- digit formats (default is 4-digit)
The allowable values are 1901 to 2155, and 0000 in the 4 year format and 1970-2069 if you use the 2 digit format (70-69). MySQL displays YEAR values in YYYY format, but allows you to assign values to YEAR columns using either strings or numbers. (The YEAR type is new in MySQL 3.22.)
CHAR
A fixed-length string that is always right-padded with spaces to the specified length when stored
The range of Length is 1 to 255 characters. Trailing spaces are removed when the value is retrieved. CHAR values are sorted and compared in case-insensitive fashion according to the default character set unless the BINARY keyword is given
VARCHAR
A variable-length string. Note: Trailing spaces are removed when the value is stored (this differs from the ANSI SQL specification)
The range of Length is 1 to 255 characters. VARCHAR values are sorted and compared in case-insensitive fashion unless the BINARY keyword is given
TINYBLOB,
TINYTEXT
A BLOB or TEXT column with a maximum length of 255 (2^8 - 1) characters
BLOB,
TEXT
A BLOB or TEXT column with a maximum length of 65535 (2^16 - 1) characters
MEDIUMBLOB,
MEDIUMTEXT
A BLOB or TEXT column with a maximum length of 16777215 (2^24 - 1) characters
LONGBLOB,
LONGTEXT
A BLOB or TEXT column with a maximum length of 4294967295 (2^32 - 1) characters
ENUM
An enumeration
A string object that can have only one value, chosen from the list of values ‘value1’, ‘value2’, ..., or NULL. An ENUM can have a maximum of 65535 distinct values.
SET
A set
A string object that can have zero or more values, each of which must be chosen from the list of values ‘value1’, ‘value2’, ... A SET can have a maximum of 64 members
,打算到documentation,INT(8)
意味着你設定的顯示寬度到「至少8」,但是:
顯示寬度不約束可以存儲在列中的值的範圍。它也不會阻止比列顯示寬度更寬的值被正確顯示。
- 1. 含義((INT *)的ptr + 1)
- 2. *(int *)在C中的含義
- 3. INT不包含定義值
- 4. 「@far int * @near IntegerPointer;」的含義
- 5. MySQL int定義說明
- 6. int(0)在int * pi = new int(0)中的含義;?
- 7. *(volatile unsigned int *)的含義0x00 = 0x00;
- 8. 「typedef void(* __ handler)(int)」的含義是什麼?
- 9. java.io.BufferedWriter.min(int a,int b)的含義是什麼?
- 10. mySQL count(*)數組的含義
- 11. 「?」的含義在MySQL查詢
- 12. Mysql:允許空含義
- 13. *和的含義。在MySQL
- 14. LINQ到SQL錯誤:「INT []」不包含定義爲「包含」
- 15. MySQL INT(x)與INT(x + 1)
- 16. INT []包含在EF6
- 17. Mysql bigint到int
- 18. MYSQL INT另外
- 19. PHP INT由MySQL
- 20. C#不能含蓄轉換INT []爲int
- 21. Objective-C檢查包含int的數組是否包含int
- 22. MySQL中'默認數據庫'的含義
- 23. information_schema.TABLES.DATA_FREE在MySQL中的含義是什麼?
- 24. MySQL更新語句中「>」的含義
- 25. 在mysql中解釋計劃的含義
- 26. Mysql select包含字符串+特定int列的比較
- 27. MySQL int()無限制
- 28. MySQL Int刪除0
- 29. MySQL的最低INT
- 30. 更改MYSQL INT值
本文檔([http://www.nhn.ou.edu/~baron/num_meths/Unsigned_and_Signed_Integers.pdf](http://www.nhn.ou.edu/~baron /num_meths/Unsigned_and_Signed_Integers.pdf))應該回答你所有的問題。 – tomthorgal