SQL数据类型 – SQL Server中的数据类型

SQL数据类型 - SQL Server中的数据类型
1. SQL数据类型

在上一期SQL教程中,我们讨论了SQL运算符。今天,我们将看到SQL数据类型。首先,我们将看一下SQL中的数据类型。此外,我们将讨论SQL常规数据类型和6种主要使用SQL Server数据类型。
因此,让我们开始SQL数据类型。

SQL数据类型

SQL数据类型| SQL Server中的数据类型

2. SQL中的数据类型是什么?

非常数据库表中的每一列都需要具有名称和数据类型。 SQL开发人员应该确定一旦创建SQL表,每个表列中将保留哪些数据类型。该类型可以是SQL的标签和宗旨,以了解每列中预期有哪些数据,并另外标识。但是,SQL可以处理keep数据。

您了解SQL RDBMS概念

3. SQL常规数据类型

以下是一些常规SQL数据类型及其描述:

Data Type Description
CHARACTER(n) Character string with fixed length n
VARCHAR(n) or
CHARACTER VARYING(n)
It is character string with fixed maximum variable length n
BINARY(n) It is a binary string with a fixed length
BOOLEAN This stores TRUE or FALSE values.
VARBINARY(n) or
BINARY VARYING(n)
It is a binary string with fixed variable length n.
INTEGER(p) It is an integer numerical with no decimal, here p is precision
SMALLINT It is also an integer numerical with no decimal and precision 5
INTEGER It is the same as the mentioned above types with the only difference of precision 10
BIGINT Here precision is 19
DECIMAL(p,s) It is an exact numerical with precision p and scale s
NUMERIC(p,s) It is an exact numerical with numerical with precision p and scale s
FLOAT It is an approximate numerical with mantissa precision 16
REAL It is an approximate numerical with mantissa precision 7
FLOAT(p) It is an approximate numerical with mantissa precision p, in this type a single precision is mentioned which specifies the minimum value.
DOUBLE PRECISION It is an approximate numerical with mantissa precision 16
DATE It stores the value for a date, time and the days
TIME It stores the value of seconds, minutes and hours
ARRAY It stores the value of seconds, minutes, hours, months and years
MULTISET It is an unordered collection of elements of variable length
XML This stores XML data
TIMESTAMP An ordered collection of data with a set length
INTERVAL It represents a period of time, which depends on the interval time and is composed of integer fields

看看RDBMS数据库系统

TINYTEXT Holds a string with a most extreme length of 255 characters
TEXT Holds a string with a most extreme length of 65,535 characters
BLOB For BLOBs (Binary Large Object). Holds up to 65,535 bytes of information
MEDIUMTEXT Holds a string with a most extreme length of 16,777,215 characters
MEDIUMBLOB For BLOBs (Binary Large Object). It holds up to 16,777,215 bytes of information
LONGTEXT Holds a string with a most extreme length of 4,294,967,295 characters
LONGBLOB For BLOBs (Binary Large Object). Holds up to 4,294,967,295 bytes of information
ENUM(x,y,z,etc.) Let you enter a rundown of conceivable qualities. You can list up to 65535 qualities in an ENUM list. In the event that an esteem is embedded, that isn’t in the rundown, a clear esteem will be embedded.
SET Similar to ENUM with the exception of that SET may contain up to 64 list things and can store in excess of one decision

4. SQL Server数据类型
SQL Server提供6种类型的数据类型。 让我们一一讨论:

a.确切的数值数据类型SQL

  • bigint 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
  • int  –2,147,483,648 to 2,147,483,647
  • smallint 32,768 to 32,767
  • tinyint 0 to 255
  • bit 0 to 1
  • decimal 10^38 +1 to 10^38 -1
  • numeric  –10^38 +1 to 10^38 -1
  • money 922,337,203,685,477.5808 to +922,337,203,685,477.5807
  • smallmoney  –214,748.3648 to +214,748.3647

b.近似数值数据类型

  • float 1.79E + 308 to 1.79E + 308
  • real 3.40E + 38 to 3.40E + 38

C.日期和时间SQL数据类型

  • datetime
  • smalldatetime
  • date
  • time

d.字符串数据类型

  • char
  • varchar
  • varchar(max)
  • text

e.Unicode字符串数据类型

  • nchar
  • nvarchar
  • nvarchar(max)
  • ntext

F.二进制数据类型

  • binary
  • varbinary
  • varbinary(max)
  • image

G。杂项数据类型

  • sql_variant
  • timestamp
  • uniqueidentifier
  • xml
  • cursor
  • table

因此,所有这些都在SQL数据类型中。希望您喜欢我们的解释。

5.结论

因此,在本“ SQL数据类型”教程中,我们了解了SQL中使用的常规数据类型。此外,我们讨论了6种基本的SQL Server数据类型。不过,如果有任何有关SQL数据类型的查询,请在注释选项卡中询问。

本文由 学习链 作者:学习链 发表,其版权均为 学习链 所有,文章内容系作者个人观点,不代表 学习链 对观点赞同或支持,未经许可,禁止转载,题图来自Unsplash,基于CC0协议。

发表评论