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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:00:46  来源:igfitidea点击:

What is the difference between int and integer in MySQL 5.0?

mysqltypesinteger

提问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

摘自MYSQL 5.0 在线参考

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 INTEGERtype but no INTtype.

这样,您将有更好的机会在其他 DBMS 上使用您的 SQL 脚本。例如PostgresSQLINTEGER类型但没有INT类型。

回答by juma bonivanture

The difference between intand integer is that intis a data type, but integer is a group of data types – e.g. int, long, shortand byte.

之间的差int和整数是int是一种数据类型,但整数是一组数据类型-例如intlongshortbyte