Home Database Mysql Tutorial SQL Server数据类型

SQL Server数据类型

Jun 07, 2016 pm 05:38 PM
server data type

转载: 数据类型是数据的一种属性,是数据所表示信息的类型。任何一种语言都有它自己所固有的数据类型,SQL Server提供一下25种固有的数据类型。 SQL Server数据类型一览表 ·Binary [(n)] ·Varbinary [(n)] ·Char [(n)] ·Varchar[(n)] ·Nchar[(n)] ·Nv

转载:

   数据类型是数据的一种属性,是数据所表示信息的类型。任何一种语言都有它自己所固有的数据类型,SQL Server提供一下25种固有的数据类型。

SQL Server数据类型一览表
·Binary [(n)]
·Varbinary [(n)]
·Char [(n)]
·Varchar[(n)]
·Nchar[(n)]
·Nvarchar[(n)]
·Datetime
·Smalldatetime
·Decimal[(p[,s])]
·Numeric[(p[,s])]
·Float[(n)]
·Real
·Int
·Smallint
·Tinyint
·Money
·Smallmoney
·Bit
·Cursor
·Sysname
·Timestamp
·Uniqueidentifier
·Text
·Image
·Ntext

1、二进制数据类型:
      二进制数据由十六进制数表示,可以使用 binary、varbinary 和 image 数据类型存储。
·binary 固定长度(最多为8K)的二进制数据类型。

binary [ ( n ) ]
固定长度的 n 个字节二进制数据。N 必须从 1 到 8,000。存储空间大小为 n+4 字节。

·varbinary 可变长度(最多为8K)的二进制数据类型。

varbinary [ ( n ) ]
      n 个字节变长二进制数据。n 必须从 1 到 8,000。存储空间大小为实际输入数据长度 +4
      个字节,而不是 n 个字节。输入的数据长度可能为 0 字节。在 SQL-92 中 varbinary 的
      同义词为 binary varying。

·image 用来存储长度超过 8 KB 的可变长度的二进制数据。
      除非数据长度超过 8KB,否则一般宜用 varbinary 类型来存储二进制数据。一般用来存放 Microsoft Word 文档、Microsoft Excel 电子表格、包含位图的图像、图形交换格式 (GIF) 文件和联合图像专家组 (JPEG) 文件。
      在 Image 数据类型中存储的数据是以位字符串存储的,不是由 SQL Server 解释的,必须由应用程序来解释。例如,应用程序可以使用BMP、TIEF、GIF 和 JPEG 格式把数据存储在 Image 数据类型中。

2、字符数据类型
      字符数据由字母、符号和数字组成。使用 char、varchar 和 text 数据类型存储。
·char 固定长度(不超过 8 KB)的字符数据类型。

      char[(n)]
      长度为 n 个字节的固定长度且非 Unicode 的字符数据。n 必须是一个介于 1 和 8,000
      之间的数值。存储大小为 n 个字节。char 在 SQL-92 中的同义词为 character。

·varchar 可变长度(不超过 8 KB)的字符数据类型。

      varchar[(n)]
      长度为 n 个字节的可变长度且非 Unicode 的字符数据。n 必须是一个介于 1 和 8,000
      之间的数值。存储大小为输入数据的字节的实际长度,而不是 n 个字节。所输入的数据字
      符长度可以为零。varchar 在SQL-92 中的同义词为char varying 或character varying。

·text 数据类型的列可用于存储大于 8KB 的 ASCII 字符。
      例如,由于 HTML 文档均由 ASCII 字符组成且一般长于 8KB,所以用浏览器查看之前应在 SQL Server 中存储在 text 列中。

3、Unicode数据类型
      使用 Unicode 数据类型,列可存储由 Unicode 标准定义的任何字符,包含由不同字符集定义的所有字符。Unicode 数据使用 SQL Server 中的 nchar、varchar 和 ntext 数据类型进行存储。
·nchar 固定长度(至多为 4000 个 Unicode 字符)的Unicode数据类型。

      nchar(n) 包含n 个字符的固定长度Unicode字符数据。n的值必须介于1与4,000之间。存储大小为n字
      节的两倍。nchar 在 SQL-92 中的同义词为 national char 和 national character。

·nvarchar ( varchar ) 是可变长度 Unicode 数据的数据类型。

      nvarchar(n) 包含 n 个字符的可变长度 Unicode 字符数据。n 的值必须介于 1 与 4,000 之间。
      字节的存储大小是所输入字符个数的两倍。所输入的数据字符长度可以为零。nvarchar 在 SQL-92 中的同义词为 national char varying 和 national character varying。

·ntext 当列中任意项超过 4000 个 Unicode字符时使用。

4、日期和时间数据类型
      日期和时间数据由有效的日期或时间组成。例如,有效日期和时间数据既包括"4/01/98 12:15:00:00:00 PM",也包括"1:28:29:15:01 AM 8/17/98"。在 Microsoft SQL Server 2000 中,日期和时间数据使用 datetime 和 smalldatetime 数据类型存储。
·datetime
数据类型存储从 1753 年 1 月 1 日至 9999 年 12 月 31 日的日期。
      每个数值要求 8 个字节的存储空间。

·smalldatetime
数据类型存储从 1900 年 1 月 1 日至 2079 年 6 月 6 日的日期。
      每个数值要求 4 个字节的存储空间。

·设置日期
格式的命令如下:
      Set DateFormat {format | @format _var|
      其中,format | @format_var 是日期的顺序。有效的参数包括 MDY、DMY、YMD、
      YDM、MYD 和 DYM。在默认情况下,日期格式为MDY。

5、数字数据类型
      数字数据只包含数字。数字数据包括正数、负数、小数、分数和整数。
·整型数据
整型数据由负整数或正整数组成,如 -15、0、5 和 2509。在 Microsoft SQL Server
      2000 中,整型数据使用 bigint、int、smallint 和 tinyint 数据类型存储。bigint 数据类
      型可存储的数字范围比 int 数据类型广。int 数据类型比 smallint 数据类型的存储范围
      大,而 smallint 的数值范围又比 tinyint 类型大。

      bigint 存储从-2^63 (-9223372036854775808)到2^63-1(9223372036854775807) 范围内的
        数字。存储大小为 8 个字节。

int 存储范围是-2,147,483,648至2,147,483,647(每个值需4个字节的存储空间)。

smallint 存储范围只有 -32,768 至 32,767(每个值需 2 个字节的存储空间)。

      tinyint 只能存储 0 至 255 范围内的数字(每个值需 1 个字节的存储空间)。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Apr 03, 2024 pm 12:04 PM

0.What does this article do? We propose DepthFM: a versatile and fast state-of-the-art generative monocular depth estimation model. In addition to traditional depth estimation tasks, DepthFM also demonstrates state-of-the-art capabilities in downstream tasks such as depth inpainting. DepthFM is efficient and can synthesize depth maps within a few inference steps. Let’s read about this work together ~ 1. Paper information title: DepthFM: FastMonocularDepthEstimationwithFlowMatching Author: MingGui, JohannesS.Fischer, UlrichPrestel, PingchuanMa, Dmytr

Use ddrescue to recover data on Linux Use ddrescue to recover data on Linux Mar 20, 2024 pm 01:37 PM

DDREASE is a tool for recovering data from file or block devices such as hard drives, SSDs, RAM disks, CDs, DVDs and USB storage devices. It copies data from one block device to another, leaving corrupted data blocks behind and moving only good data blocks. ddreasue is a powerful recovery tool that is fully automated as it does not require any interference during recovery operations. Additionally, thanks to the ddasue map file, it can be stopped and resumed at any time. Other key features of DDREASE are as follows: It does not overwrite recovered data but fills the gaps in case of iterative recovery. However, it can be truncated if the tool is instructed to do so explicitly. Recover data from multiple files or blocks to a single

Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Apr 01, 2024 pm 07:46 PM

The performance of JAX, promoted by Google, has surpassed that of Pytorch and TensorFlow in recent benchmark tests, ranking first in 7 indicators. And the test was not done on the TPU with the best JAX performance. Although among developers, Pytorch is still more popular than Tensorflow. But in the future, perhaps more large models will be trained and run based on the JAX platform. Models Recently, the Keras team benchmarked three backends (TensorFlow, JAX, PyTorch) with the native PyTorch implementation and Keras2 with TensorFlow. First, they select a set of mainstream

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks Apr 29, 2024 pm 06:55 PM

I cry to death. The world is madly building big models. The data on the Internet is not enough. It is not enough at all. The training model looks like "The Hunger Games", and AI researchers around the world are worrying about how to feed these data voracious eaters. This problem is particularly prominent in multi-modal tasks. At a time when nothing could be done, a start-up team from the Department of Renmin University of China used its own new model to become the first in China to make "model-generated data feed itself" a reality. Moreover, it is a two-pronged approach on the understanding side and the generation side. Both sides can generate high-quality, multi-modal new data and provide data feedback to the model itself. What is a model? Awaker 1.0, a large multi-modal model that just appeared on the Zhongguancun Forum. Who is the team? Sophon engine. Founded by Gao Yizhao, a doctoral student at Renmin University’s Hillhouse School of Artificial Intelligence.

Slow Cellular Data Internet Speeds on iPhone: Fixes Slow Cellular Data Internet Speeds on iPhone: Fixes May 03, 2024 pm 09:01 PM

Facing lag, slow mobile data connection on iPhone? Typically, the strength of cellular internet on your phone depends on several factors such as region, cellular network type, roaming type, etc. There are some things you can do to get a faster, more reliable cellular Internet connection. Fix 1 – Force Restart iPhone Sometimes, force restarting your device just resets a lot of things, including the cellular connection. Step 1 – Just press the volume up key once and release. Next, press the Volume Down key and release it again. Step 2 – The next part of the process is to hold the button on the right side. Let the iPhone finish restarting. Enable cellular data and check network speed. Check again Fix 2 – Change data mode While 5G offers better network speeds, it works better when the signal is weaker

The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. May 07, 2024 pm 05:00 PM

Recently, the military circle has been overwhelmed by the news: US military fighter jets can now complete fully automatic air combat using AI. Yes, just recently, the US military’s AI fighter jet was made public for the first time and the mystery was unveiled. The full name of this fighter is the Variable Stability Simulator Test Aircraft (VISTA). It was personally flown by the Secretary of the US Air Force to simulate a one-on-one air battle. On May 2, U.S. Air Force Secretary Frank Kendall took off in an X-62AVISTA at Edwards Air Force Base. Note that during the one-hour flight, all flight actions were completed autonomously by AI! Kendall said - "For the past few decades, we have been thinking about the unlimited potential of autonomous air-to-air combat, but it has always seemed out of reach." However now,

The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training Mar 11, 2024 pm 12:10 PM

This week, FigureAI, a robotics company invested by OpenAI, Microsoft, Bezos, and Nvidia, announced that it has received nearly $700 million in financing and plans to develop a humanoid robot that can walk independently within the next year. And Tesla’s Optimus Prime has repeatedly received good news. No one doubts that this year will be the year when humanoid robots explode. SanctuaryAI, a Canadian-based robotics company, recently released a new humanoid robot, Phoenix. Officials claim that it can complete many tasks autonomously at the same speed as humans. Pheonix, the world's first robot that can autonomously complete tasks at human speeds, can gently grab, move and elegantly place each object to its left and right sides. It can autonomously identify objects

Alibaba 7B multi-modal document understanding large model wins new SOTA Alibaba 7B multi-modal document understanding large model wins new SOTA Apr 02, 2024 am 11:31 AM

New SOTA for multimodal document understanding capabilities! Alibaba's mPLUG team released the latest open source work mPLUG-DocOwl1.5, which proposed a series of solutions to address the four major challenges of high-resolution image text recognition, general document structure understanding, instruction following, and introduction of external knowledge. Without further ado, let’s look at the effects first. One-click recognition and conversion of charts with complex structures into Markdown format: Charts of different styles are available: More detailed text recognition and positioning can also be easily handled: Detailed explanations of document understanding can also be given: You know, "Document Understanding" is currently An important scenario for the implementation of large language models. There are many products on the market to assist document reading. Some of them mainly use OCR systems for text recognition and cooperate with LLM for text processing.

See all articles