sql二进制转十进制_了解SQL十进制数据类型

sql二进制转十进制 This article aims to walk you through the SQL Decimal data type and its usage with various examples. We will also see how we can exercise this data type in SQL Server to help make SQL de...
摘要由CSDN通过智能技术生成

sql二进制转十进制

This article aims to walk you through the SQL Decimal data type and its usage with various examples. We will also see how we can exercise this data type in SQL Server to help make SQL developer’s job easier.

本文旨在通过各种示例逐步介绍SQL Decimal数据类型及其用法。 我们还将看到如何在SQL Server中使用此数据类型,以帮助简化SQL开发人员的工作。

介绍 (Introduction)

Organizations deal with decimals on a day-to-day basis, and these decimal values can be seen everywhere in different sectors, be it in banks, the medical industry, biometrics, gas stations, financial reports, sports, and whatnot. Using whole numbers (by rounding decimal numbers) definitely makes one’s job easier but it often leads to inaccurate outputs, especially when we are dealing with a large number of values and crucial data. In such scenarios, it is ideal to use Sql Decimal data type in SQL Server to deliver correct results with perfect precision.

组织每天处理小数,这些十进制值可以在银行,医疗行业,生物识别,加油站,财务报告,体育等各种地方的不同部门中随处可见。 使用整数(通过四舍五入十进制数)无疑会使人的工作更轻松,但通常会导致输出不准确,尤其是当我们处理大量的值和关键数据时。 在这种情况下,理想的是在SQL Server中使用Sql Decimal数据类型来以完美的精度提供正确的结果。

It becomes very essential for SQL developers to choose the correct data types in the table structure while designing and modeling SQL databases. Let’s move forward and explore Decimal data type in SQL Server.

对于SQL开发人员来说,在设计和建模SQL数据库时选择表结构中的正确数据类型变得非常重要。 让我们继续前进,探索SQL Server中的Decimal数据类型。

前提条件 (Pre-requisite )

SQL Decimal data type is being used in SQL Server since forever. You can use any SQL Server version installed (starting 2000 or above) to understand this data type. We will be using SQL Server 2017 in this article for the demo purposes. If you don’t have any version installed on your system and wish to practice against the 2017 version, download it from here.

SQL Decimal数据类型从一开始就在SQL Server中使用。 您可以使用安装的任何SQL Server版本(从2000或更高版本开始)来了解此数据类型。 我们将在本文中使用SQL Server 2017进行演示。 如果您的系统上未安装任何版本,并希望针对2017版本进行练习,请从此处下载。

SQL Server中的十进制数据类型的基本语法 (The Basic syntax of Decimal data type in SQL Server)

Let’s take a look at the basic syntax of SQL Decimal Data type first. It is denoted as below:

首先让我们看一下SQL Decimal Data类型的基本语法。 表示如下:

  • decimal [(p [,s])]

    十进制[[p [,s])]

Where,

哪里,

  • p stands for Precision, the total number of digits in the value, i.e. on both sides of the decimal point

    p代表精度,即值中的位数总数,即小数点的两侧
  • s stands for Scale, number of digits after the decimal point

    s代表Scale&
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值