zoukankan      html  css  js  c++  java
  • PostgreSQL类型转换

       1.int装string

       select CAST (1234 AS text)

    select to_char(1234,’999‘)
    2.string转int
    select cast('999' as NUMERIC)


    --5 附: PostgreSQL 类型转换函数

    
    

     

    
    

    FunctionReturn TypeDescriptionExample


    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)
     
  • 相关阅读:
    HDOJ 1207 汉诺塔II
    [转]写代码的小女孩
    POJ Subway tree systems
    HDOJ 3555 Bomb (数位DP)
    POJ 1636 Prison rearrangement (DP)
    POJ 1015 Jury Compromise (DP)
    UVA 10003
    UVA 103 Stacking Boxes
    HDOJ 3530 Subsequence
    第三百六十二、三天 how can I 坚持
  • 原文地址:https://www.cnblogs.com/esther-qing/p/5908593.html
Copyright © 2011-2022 走看看