PostgreSQL類型轉換

來源:互聯網
上載者:User

標籤:

   1.int裝string

   select CAST (1234 AS text)

 

select to_char(1234,’999‘)

 

2.string轉int
select cast(‘999‘ as NUMERIC)


--5 附: PostgreSQL 類型轉換函式


 


Function Return Type Description Example


to_char
(timestamp, text

)


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‘)


to_char
(
double

precision
, text
)


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類型轉換

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.