db2字符串转date_DB2中字符、数字和日期类型之间的转换(The transformation between characters, Numbers, and date types in DB...

DB2中字符、数字和日期类型之间的转换(The transformation between characters, Numbers, and date types in DB2)

DB2中字符、数字和日期类型之间的转换(The transformation between characters, Numbers, and date types in DB2)

We are using DB2 or Oracle, often do the conversion between digital character types date three < - > < - >, then the DB2 and Oracle, they are how to achieve it? The conversion between the several types of Oracle is very convenient, through the to_char| to_date|to_number function to complete the type conversion. This section introduces some of the DB2 knowledge, from the Oracle turn DBA or developers, you can compare learning.

Conversion from numeric to character type

Test it:

SQL>create, table, test_datatypeSQL> (SQL>col_a, smallint, SQL>col_b, integer, SQL>col_c, bigint, SQL>col_d, decimal (8,2), SQL>col_e, doubleSQL>); the DB20000I SQL command is successfully completed.

SQL>insert into test_datatype values (1,2030004000.4455555); the DB20000I SQL command is successfully completed.

SQL>describe select * from test_datatype column information

Number of columns: 5

SQL type type length column name length

------------------------------------------------------------------------

501 SMALLINT 2 COL_A 5

497 INTEGER 4 COL_B 5

493 BIGINT 8 COL_C 5

485 DECIMAL 8, 2 COL_D 5

481 DOUBLE 8 COL_E 5

SQL>select * from test_datatype; COL_A, COL_B, COL_C, COL_D, COL_E

-----------------------------------------------------------------------

12030004000.44 +5.55550000000000E+004

The 1 record has been selected.

SQL>select, char (col_a), char (col_b), char (col_c), digits (col_d), char (cast (col_e, as, decimal (8,2))) from test_datatype; 12345

-------------------------------------------------------

120300000400044, 55555

The 1 record has been selected.

SQL>select char (col_a) ||','||char (col_b) ||','||char (col_c) ||','||digits (col_d) ||','||char (cast (col_e as decimal from test_datatype (8,2))); 1

-----------------------------------------------------------

1, 20, 3000, 400044055555

The 1 record has been selected.

SQL> character to digital conversion

The col_a field in DB2

Field type numeric type

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值