2025年sql文件格式(sql文件格式是哪几种)

sql文件格式(sql文件格式是哪几种)sql 数据类型 SQL Data Types define the type of value that can be stored in a table column For example if we want a column to store only integer values then we can define it s data type as

大家好,我是讯享网,很高兴认识大家。



sql数据类型

SQL Data Types define the type of value that can be stored in a table column. For example, if we want a column to store only integer values, then we can define it’s data type as .

SQL数据类型定义可以存储在表列中的值的类型。 例如,如果我们希望一列仅存储整数值,则可以将其数据类型定义为 。

SQL data types can be broadly divided into following categories.

SQL数据类型可以大致分为以下几类。


讯享网

  1. Numeric data types such as int, tinyint, bigint, float, real etc. 数值数据类型,例如int,tinyint,bigint,float,real等。
  2. Date and Time data types such as Date, Time, Datetime etc. 日期和时间数据类型,例如日期,时间,日期时间等。
  3. Character and String data types such as char, varchar, text etc. 字符和字符串数据类型,例如char,varchar,text等。
  4. Unicode character string data types, for example nchar, nvarchar, ntext etc. Unicode字符串数据类型,例如nchar,nvarchar,ntext等。
  5. Binary data types such as binary, varbinary etc. 二进制数据类型,例如binary,varbinary等。
  6. Miscellaneous data types – clob, blob, xml, cursor, table etc. 其他数据类型-clob,blob,xml,游标,表等

SQL数据类型要点 (SQL Data Types important points)

  • Not all data types are supported by every relational database vendors. For example, Oracle database doesn’t support DATETIME and MySQL doesn’t support CLOB data type. So while designing database schema and writing sql queries, make sure to check if the data types are supported or not. 并非每个关系数据库供应商都支持所有数据类型。 例如,Oracle数据库不支持DATETIME,而MySQL不支持CLOB数据类型。 因此,在设计数据库架构和编写sql查询时,请确保检查是否支持数据类型。
  • Data types listed here doesn’t include all the data types, these are the most popularly used data types. Some relational database vendors have their own data types that might be not listed here. For example, Microsoft SQL Server has and data types but since it’s not supported by other popular database vendors, it’s not listed here. 此处列出的数据类型并不包括所有数据类型,而是最常用的数据类型。 一些关系数据库供应商有其自己的数据类型,此处可能未列出。 例如,Microsoft SQL Server具有和数据类型,但是由于其他流行的数据库供应商不支持它,因此未在此处列出。
  • Every relational database vendor has it’s own maximum size limit for different data types, you don’t need to remember the limit. Idea is to have the knowledge of what data type to be used in a specific scenario. 每个关系数据库供应商对于不同的数据类型都有自己的最大大小限制,您不必记住该限制。 想法是了解在特定情况下将使用哪种数据类型。

Let’s look into different categories of sql data types in detail.

让我们详细研究sql数据类型的不同类别。

SQL数值数据类型 (SQL Numeric Data Types)

DatatypeFromTobit01tinyint0255smallint-32,76832,767int-2,147,483,6482,147,483,647bigint-9,223,372,036, 854,775,8089,223,372,036, 854,775,807decimal-10^38 +110^38 -1numeric-10^38 +110^38 -1float-1.79E + 3081.79E + 308real-3.40E + 383.40E + 38
数据类型 从 至 一点 0 1个 tinyint 0 255 Smallint -32,768 32,767 整型 -2,147,483,648 2,147,483,647 比金特 -9,223,372,036、854,775,808 9,223,372,036、854,775,807 小数 -10 ^ 38 +1 10 ^ 38 -1 数字 -10 ^ 38 +1 10 ^ 38 -1 浮动 -1.79E + 308 1.79E + 308 真实 -3.40E + 38 3.40E + 38

SQL日期和时间数据类型 (SQL Date and Time Data Types)

DatatypeDescriptionDATEStores date in the format YYYY-MM-DDTIMEStores time in the format HH:MI:SSDATETIMEStores date and time information in the format YYYY-MM-DD HH:MI:SSTIMESTAMPStores number of seconds passed since the Unix epoch (‘1970-01-01 00:00:00’ UTC)YEARStores year in 2 digit or 4 digit format. Range 1901 to 2155 in 4-digit format. Range 70 to 69, representing 1970 to 2069.
数据类型 描述 日期 以YYYY-MM-DD格式存储日期 时间 以HH:MI:SS格式存储时间 约会时间 以YYYY-MM-DD HH:MI:SS格式存储日期和时间信息 时间戳 存储自Unix纪元(‘1970-01-01 00:00:00’UTC)起经过的秒数 年 以2位数或4位数格式存储年份。 以4位数格式表示的范围为1901至2155。 范围从70到69,代表1970到2069。

SQL字符和字符串数据类型 (SQL Character and String Data Types)

DatatypeDescriptionCHARFixed length with maximum length of 8,000 charactersVARCHARVariable length storage with maximum length of 8,000 charactersVARCHAR(max)Variable length storage with provided max characters, not supported in MySQLTEXTVariable length storage with maximum size of 2GB data
数据类型 描述 焦炭 固定长度,最大长度为8,000个字符 VARCHAR 可变长度存储,最大长度为8,000个字符 VARCHAR(最大值) 具有最大字符数的可变长度存储,MySQL不支持 文本 可变长度存储,最大大小为2GB数据

Note that all the above data types are for character stream, they should not be used with unicode data.

请注意,以上所有数据类型均用于字符流,不应将它们与unicode数据一起使用。

SQL Unicode字符和字符串数据类型 (SQL Unicode Character and String Data Types)

DatatypeDescriptionNCHARFixed length with maximum length of 4,000 charactersNVARCHARVariable length storage with maximum length of 4,000 charactersNVARCHAR(max)Variable length storage with provided max charactersNTEXTVariable length storage with maximum size of 1GB data
数据类型 描述 NCHAR 固定长度,最大长度为4,000个字符 NVARCHAR 可变长度存储,最大长度为4,000个字符 NVARCHAR(最大) 具有最大字符数的可变长度存储 文本 可变长度存储,最大大小为1GB数据

Note that above data types are not supported in MySQL database.

请注意,MySQL数据库不支持上述数据类型。

SQL二进制数据类型 (SQL Binary Data Types)

DatatypeDescriptionBINARYFixed length with maximum length of 8,000 bytesVARBINARYVariable length storage with maximum length of 8,000 bytesVARBINARY(max)Variable length storage with provided max bytesIMAGEVariable length storage with maximum size of 2GB binary data
数据类型 描述 二进制 固定长度,最大长度为8,000个字节 VARBINARY 可变长度存储,最大长度为8,000字节 VARBINARY(最大) 提供最大字节数的可变长度存储 图片 可变长度存储,最大大小为2GB二进制数据

SQL杂项数据类型 (SQL Miscellaneous Data Types)

DatatypeDescriptionCLOBCharacter large objets that can hold up to 2GBBLOBFor binary large objectsXMLfor storing xml dataJSONfor storing JSON data
数据类型 描述 CLOB 字符大的对象,最多可容纳2GB BLOB 对于二进制大对象 XML格式 用于存储xml数据 JSON格式 用于存储JSON数据

That’s all for a quick roundup on SQL data types.

这就是快速汇总SQL数据类型的全部内容。

Reference: Oracle Database Data Types, mySQL Data Types

参考: Oracle数据库数据类型 , mySQL数据类型

翻译自: https://www.journaldev.com/16774/sql-data-types

sql数据类型

小讯
上一篇 2025-04-16 09:35
下一篇 2025-06-11 15:05

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/207556.html