INTの値を8にしても、1から99999999まで、または1から4294967295のUNSIGNEDしか使用できないのでしょうか?MySQL INTの意味
答えて
ドキュメントには、このことについて、かなり明確なようだ:
数値型は
MySQLは、必要に応じて基本キーワードに続く括弧内の整数データ型のディスプレイ 幅を指定するための拡張機能をサポートしています属性タイプの場合は です。たとえば、INT(4)は、ディスプレイ の幅4桁のINTを指定します。このオプションの表示幅は、 アプリケーションで、列に指定された幅が より小さい整数値をスペースで左に埋めて表示するために使用されます。表示幅が を格納することができる値の範囲を制限しない
( この幅は、結果セットで返されたメタデータに存在する、である。それが使用されるかどうか かはアプリケーション次第である。ように)列にまた、列幅 の幅よりも広い値が正しく表示されないこともありません。たとえば、SMALLINT(3)として指定された列 は、通常のSMALLINT範囲が-32768〜 32767であり、3桁で許可された範囲外の値は、3桁を超えてフルで表示される です。
mysql documentationをご覧ください。すべてのデータ型の詳細を知ることができます。符号なしの場合、最大値は4294967295です。
INTの値フィールドでは4294967295に設定する必要がありますか? – Warface
明示的に符号なし整数を選択する必要があります。符号付き整数で、デフォルトでは符号付き整数であるため、ネガも使用できます。 Tom Squiresが提供するリンクのドキュメントを見てください。
ところで、私が見つけたものを見 - > *の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)
はあなたが表示幅を設定することを意味し
表示幅は、列に格納できる値の範囲を制限しません。また、列の表示幅よりも広い値が正しく表示されないこともありません。
- 1. MySQL:サブクエリ:警告メッセージ意味
- 2. int test [] = new int [0]はどういう意味ですか?
- 3. mysqlのCREATE TABLE文のKEYの意味
- 4. mysql(MEDIUMINT)の3バイトの意味
- 5. typecastingの場合、これは*(int *)&xを意味しますか?
- 6. int max =〜0;どういう意味ですか?
- 7. これはc int a:16;で何を意味しますか?
- 8. "int * const * b"とは何を意味していますか?
- 9. 意味
- 10. 意味
- 11. 意味
- 12. 意味
- 13. 意味
- 14. 意味
- 15. ORMの意味は?
- 16. MAX_USER_CONNECTIONSエラーの意味と
- 17. ``?( '')??? `の意味は?
- 18. SEQUENCE_NEXT_HI_VALUEの意味
- 19. 「...」の意味と 『##』
- 20. "スレッドダンプ"の意味
- 21. setContextClassLoaderの意味
- 22. :/ =%%の意味:/ =%?
- 23. jqueryの意味
- 24. `/ * @ 'の意味は?
- 25. ステートメントの意味
- 26. 式の意味
- 27. インポートステートメントバイトコードの意味
- 28. Rのビルトイン関数定義の意味<bytecode: #>の意味
- 29. CDATAの意味は?
- 30. Salesforce doc、 ' - 'の意味
この文書([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