繁体   English   中英

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

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

我正在尝试在 oracle 数据库表中插入 dataframe,但表中的某些列的数据类型为NUMBER(20,3)

我假设这是浮动的。

如何将我的数据类型为int64的列转换为等效的NUMBER(20,3) ,因为它给出了无效的标识符错误

Oracle 中的number(20, 3)表示该列接受总共有 20 位数字的数值,并且这 20 位中的 3 位保留给小数。 例如:

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

Table created.

让我们插入一些值:

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.

表内容:没有惊喜:

SQL> select * from test;

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

如果插入超过 3 个小数位怎么办? Oracle 将执行回合

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

1 row created.

但是,您报告了无效标识符错误。 这与您插入的内容无关,而是无效的列名。 看一看:我将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>

因此,检查您使用的语句,看起来您拼错了一个(或多个)列名。 请注意列名周围的双引号(在 Oracle 中,我们通常不使用它们)并且 - 如果您有双引号 - 请注意字母大小写。


哦,是的:如何将int64转换为number(20, 3) 不知道,我不使用 Python。

暂无
暂无

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

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