插入资金时使用的SQL数据类型 [英] SQL Datatype to use when inserting money

查看:90
本文介绍了插入资金时使用的SQL数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Oracle SQL数据库,因此必须在行中插入一个货币值(工资).由于某些奇怪的原因,money命令无法正常工作,是否有其他替代方法可以使用此命令?

I am using Oracle SQL database and I have to insert a monetary value(salary) as part of a row. For some strange reason the money command isnt working, is there any alternates that would work with this?

数据输入格式:£00,000.000

Data input format: £00,000.000

CREATE TABLE staff
                   (staffno CHAR(6) NOT NULL
                    , staffsurname VARCHAR(8) NOT NULL
                    , staffforename VARCHAR(7) NOT NULL
                    , salary MONEY NOT NULL
                    , PRIMARY KEY (staffno)
                   );

推荐答案

查看此行

salary MONEY NOT NULL

没有现有的money数据类型.

There is no existing money datatype.

如果您要查找类似于SQL-Server小额钱的类型,则要使用Number(10,4),然后设置数字的格式.

If you are looking for something similar to SQL-Server small money type, you want to use a Number(10,4) and then format the number.

您可以使用to_char功能设置数字格式

You can format the number using to_char function

select to_char(yourColumn, '$99,999.99') from yourTable where someCondition

这篇关于插入资金时使用的SQL数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆