0

我必须将美元保存到我应该使用哪种数据类型的表中。我知道 Number 数据类型,但我想存储我25,0000应该使用哪种数据类型number or varchar

4

2 回答 2

1

这样做是一个糟糕的选择(因为最终有人会将损坏的字符串保存到该列并破坏您的代码)。

如果需要,我会将表格作为 anumber并在其顶部有一个视图,将 $ 连接到数字(select '$'||your_col, ...)。如果您需要多种货币,那么最好使用包含货币代码的货币列,例如USD.

于 2013-02-25T11:36:53.920 回答
1

使用数字,然后使用 TO_CHAR 和正确的格式掩码(取决于 NLS)

create table curr_test (col number);
insert into curr_test (col) values (15.25);
select to_char(col, 'L00D00') from curr_test;

链接:http ://docs.oracle.com/cd/E11882_01/server.112/e10729/ch3globenv.htm#NLSPG221

于 2013-02-25T13:44:13.600 回答