简体   繁体   English

将多个 dataframe 列 int64 dtype 转换为等效于 oracle 的 NUMBER(20,3) 数据类型

[英]convert multiple dataframe columns int64 dtype to equivalent of NUMBER(20,3) datatype of oracle

I am trying to insert dataframe in oracle DB table but some of columns in table has datatype as NUMBER(20,3)我正在尝试在 oracle 数据库表中插入 dataframe,但表中的某些列的数据类型为NUMBER(20,3)

I am assuming this is float.我假设这是浮动的。

How can convert my column having datatype as int64 to NUMBER(20,3) equivalent as it is giving invalid identifier error .如何将我的数据类型为int64的列转换为等效的NUMBER(20,3) ,因为它给出了无效的标识符错误

number(20, 3) in Oracle means that column accepts numeric value which have 20 digits in total, and 3 out of those 20 are reserved for decimals. Oracle 中的number(20, 3)表示该列接受总共有 20 位数字的数值,并且这 20 位中的 3 位保留给小数。 For example:例如:

SQL> create table test (id number, value number(20, 3));

Table created.

Let's insert some values:让我们插入一些值:

SQL> insert into test (id, value) values (1, 12.43);

1 row created.

SQL> insert into test (id, value) values (2, 12.4356);

1 row created.

SQL> insert into test (id, value) values (3, 12345678901234567.987);

1 row created.

Table contents: no surprises:表内容:没有惊喜:

SQL> select * from test;

        ID      VALUE
---------- ----------
         1      12,43
         2     12,436
         3 1,2346E+16

What if you insert more than 3 decimal digits?如果插入超过 3 个小数位怎么办? Oracle will perform round : Oracle 将执行回合

SQL> insert into test (id, value) values (4, 12.4327);

1 row created.

But, you reported invalid identifier error.但是,您报告了无效标识符错误。 That has nothing to do with contents you're inserting, but invalid column name.这与您插入的内容无关,而是无效的列名。 Have a look: I "renamed" the id column to idxyz and Oracle raised error you mentioned:看一看:我将id列“重命名”为idxyz并且 Oracle 引发了您提到的错误:

SQL> insert into test (idxyz, value) values (5, 123);
insert into test (idxyz, value) values (5, 123)
                  *
ERROR at line 1:
ORA-00904: "IDXYZ": invalid identifier


SQL>

Therefore, check statement you use, looks like you misspelled one (or more) column names.因此,检查您使用的语句,看起来您拼错了一个(或多个)列名。 Mind double quotes around column names (in Oracle, we usually don't use them) and - if you do have double quotes - mind letter case as well.请注意列名周围的双引号(在 Oracle 中,我们通常不使用它们)并且 - 如果您有双引号 - 请注意字母大小写。


Oh, yes: how to convert int64 to number(20, 3) ?哦,是的:如何将int64转换为number(20, 3) No idea, I don't use Python.不知道,我不使用 Python。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM