MySQL 5.0 中的 int 和 integer 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/688582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between int and integer in MySQL 5.0?
提问by sivakumar
What is the difference between int and integer datatypes in MySQL 5.0? Can anyone help? I don't understand the exact difference.
MySQL 5.0 中的 int 和 integer 数据类型有什么区别?任何人都可以帮忙吗?我不明白确切的区别。
回答by TechTravelThink
Taken from MYSQL 5.0 online reference
The keyword INT is a synonym for INTEGER.
关键字 INT 是 INTEGER 的同义词。
回答by ksuralta
I guess the only difference is the spelling.
我想唯一的区别是拼写。
So by using INT, you'd end up using less bytes on your SQL script (not that it matters).
因此,通过使用 INT,您最终会在 SQL 脚本中使用更少的字节(这并不重要)。
回答by Ortomala Lokni
According to the MySQL documentation:
根据 MySQL文档:
The keyword INT is a synonym for INTEGER
关键字 INT 是 INTEGER 的同义词
but if you want to write SQL scripts compatible with ANSI SQLuse INTEGER
. According to the specification:
但是如果您想编写与ANSI SQL兼容的 SQL 脚本,请使用INTEGER
. 根据规格:
SQL defines distinct data types named by the following keywords: CHARACTER, CHARACTER VARYING, BIT, BIT VARYING, NUMERIC, DECIMAL, INTEGER, SMALLINT, FLOAT, REAL, DOUBLE PRECISION, DATE, TIME, TIMESTAMP, and INTERVAL.
SQL 定义了由以下关键字命名的不同数据类型:CHARACTER、CHARACTER VARYING、BIT、BIT VARYING、NUMERIC、DECIMAL、 INTEGER、SMALLINT、FLOAT、REAL、DOUBLE PRECISION、DATE、TIME、TIMESTAMP 和 INTERVAL。
In this way, you will have better chance to use your SQL scripts on other DBMS. For example PostgresSQLhave an INTEGER
type but no INT
type.
这样,您将有更好的机会在其他 DBMS 上使用您的 SQL 脚本。例如PostgresSQL有INTEGER
类型但没有INT
类型。
回答by juma bonivanture
The difference between int
and integer is that int
is a data type, but integer is a group of data types – e.g. int
, long
, short
and byte
.
之间的差int
和整数是int
是一种数据类型,但整数是一组数据类型-例如int
,long
,short
和byte
。