发布网友 发布时间:2022-04-09 09:53
共2个回答
懂视网 时间:2022-04-09 14:14
select to_char(1234,’999‘)
2.string转int
select cast(‘999‘ as NUMERIC)
--5 附: PostgreSQL 类型转换函数
Function | Return Type | Description | Example |
---|---|---|---|
) |
text |
convert time stamp to string | to_char(current_timestamp, ‘HH12:MI:SS‘) |
to_char ( interval, text ) |
text |
convert interval to string | to_char(interval ‘15h 2m 12s‘, ‘HH24:MI:SS‘) |
to_char ( int, text ) |
text |
convert integer to string | to_char(125, ‘999‘) |
precision |
text |
convert real/double precision to string | to_char(125.8::real, ‘999D9‘) |
to_char ( numeric, text ) |
text |
convert numeric to string | to_char(-125.8, ‘999D99S‘) |
to_date (text, text ) |
date |
convert string to date | to_date(‘05 Dec 2000‘, ‘DD Mon YYYY‘) |
to_number ( text, text ) |
numeric |
convert string to numeric | to_number(‘12,454.8-‘, ‘99G999D9S‘) |
to_timestamp ( text, text ) |
timestamp with time zone |
convert string to time stamp | to_timestamp(‘05 Dec 2000‘, ‘DD Mon YYYY‘) |
to_timestamp ( double precision ) |
timestamp with time zone |
convert Unix epoch to time stamp | to_timestamp(1284352323) |
PostgreSQL类型转换
标签:
热心网友 时间:2022-04-09 11:22
select追答恩,是在查找时转换的。如果在表里,建议新建一个表,而后
insert into 新建表 (字段名1, ... 字段名n) (select 字段名1,... 要改字段::numeric,...字段名n from 老表)