Type Conversion Functions

Type Conversion Functions

  • cash_words(money)

    Description: Type conversion function, which converts money into text.

    Example:

    openGauss=# SELECT cash_words('1.23');
                cash_words
    -----------------------------------
     One dollar and twenty three cents
    (1 row)
    
  • cast(x as y)

    Description: Converts x into the type specified by y.

    Example:

    openGauss=# SELECT cast('22-oct-1997' as timestamp);
          timestamp      
    ---------------------
     1997-10-22 00:00:00
    (1 row)
    
  • hextoraw(raw)

    Description: Converts a string in hexadecimal format into raw type.

    Return type: raw

    Example:

    openGauss=# SELECT hextoraw('7D');
     hextoraw 
    ----------
     7D
    (1 row)
    
  • numtoday(numeric)

    Description: Converts values of the number type into the timestamp of the specified type.

    Return type: timestamp

    Example:

    openGauss=# SELECT numtoday(2);
     numtoday
    ----------
     2 days
    (1 row)
    
  • pg_systimestamp()

    Description: Obtains the system timestamp.

    Return type: timestamp with time zone

    Example:

    openGauss=# SELECT pg_systimestamp();
            pg_systimestamp
    -------------------------------
     2015-10-14 11:21:28.317367+08
    (1 row)
    
  • rawtohex(string)

    Description: Converts a string in binary format into hexadecimal format.

    The result is the ACSII code of the input characters in hexadecimal format.

    Return type: varchar

    Example:

    openGauss=# SELECT rawtohex('1234567');
        rawtohex    
    ----------------
     31323334353637
    (1 row)
    
  • to_bigint(varchar)

    Description: Converts the character type to the bigint type.

    Return type: bigint

    Example:

    openGauss=# SELECT to_bigint('123364545554455');
        to_bigint    
    ----------------
     123364545554455
    (1 row)
    
  • to_char(datetime/interval [, fmt])

    Description: Converts a DATETIME or INTERVAL value of the DATE/TIMESTAMP/TIMESTAMP WITH TIME ZONE/TIMESTAMP WITH LOCAL TIME ZONE type into the TEXT type according to the format specified by fmt.

    • The optional parameter fmt allows for the following types: date, time, week, quarter, and century. Each type has a unique template. The templates can be combined together. Common templates include HH, MI, SS, YYYY, MM, and DD.
    • A template may have a modification word. FM is a common modification word and is used to suppress the preceding zero or the following blank spaces.
    • Only on dbcompatibility = 'A', When the input is interval, the fmt will be ignored. If the interval only includes year and month, the output format will be SYYYY-MM. When the year is less than two digits, it will be padded with a leading zero. If the interval only includes day and time, the output format will be SDD HH:MI:SS. If the interval contains both, an error code will be returned.

    Return type: text

    Example:

    openGauss=# SELECT to_char(current_timestamp,'HH12:MI:SS');
     to_char  
    ----------
     10:19:26
    (1 row)
    
    openGauss=# SELECT to_char(current_timestamp,'FMHH12:FMMI:FMSS');
     to_char  
    ----------
     10:19:46
    (1 row)
    
  • to_char(datetime/interval, fmt, nls_language={american|english})

    Description: Similar to to_char(datetime/interval [, fmt]), an additional parameter nls_language. The possible values for nls_language are american and english.

    • Templates like MON in fmt will be converted to the corresponding language expression based on nls_language.

    Return type: text

    Example:

    openGauss=# SELECT to_char(DATE '2024-08-05', 'DY, DD-MON-YYYY', 'NLS_DATE_LANGUAGE = ENGLISH') ;
     to_char      
    ----------
     MON, 05-AUG-2024
    (1 row)
    
  • to_char(double precision/real, text)

    Description: Converts the values of the floating point type into the strings in the specified format.

    Return type: text

    Example:

    openGauss=# SELECT to_char(125.8::real, '999D99');
     to_char 
    ---------
      125.80
    (1 row)
    
  • to_char(numeric/smallint/integer/bigint/double precision/real[, fmt])

    Descriptions: Converts an integer or a value in floating point format into a string in specified format.

    • The optional parameter fmt allows for the following types: decimal characters, grouping characters, positive/negative sign and currency sign. Each type has a unique template. The templates can be combined together. Common templates include: 9, 0, millesimal sign (,), and decimal point (.).
    • A template can have a modification word, similar to FM. However, FM does not suppress 0 which is output according to the template.
    • Use the template X or x to convert an integer value into a string in hexadecimal format.

    Return type: varchar

    Example:

    openGauss=# SELECT to_char(1485,'9,999');
     to_char 
    ---------
      1,485
    (1 row)
    
    openGauss=# SELECT to_char( 1148.5,'9,999.999');
      to_char   
    ------------
      1,148.500
    (1 row)
    
    openGauss=# SELECT to_char(148.5,'990999.909');
       to_char   
    -------------
        0148.500
    (1 row)
    
    openGauss=# SELECT to_char(123,'XXX');
     to_char 
    ---------
       7B
    (1 row)
    
  • to_char(interval, text)

    Description: Converts the values of the time interval type into the strings in the specified format.

    • Only on dbcompatibility = 'A', When the input is interval, the fmt will be ignored. If the interval only includes year and month, the output format will be SYYYY-MM. When the year is less than two digits, it will be padded with a leading zero. If the interval only includes day and time, the output format will be SDD HH:MI:SS. If the interval contains both, an error code will be returned.

    Return type: text

    Example:

    openGauss=# SELECT to_char(interval '15h 2m 12s', 'HH24:MI:SS');
     to_char
    ----------
     15:02:12
    (1 row)
    
    openGauss=# SELECT to_char(INTERVAL '123-2' YEAR(4) TO MONTH, 'YYY-MON');
     to_char 
    ---------
     +123-02
    (1 row)
    
    openGauss=# SELECT to_char(INTERVAL '1 year 2 months 3 days', 'YYYY-MON-DD') ;
    ERROR:  Interval simultaneously includes 'year to month' and 'day to second' is not supported in A format
    DETAIL:  Not support the given interval data.
    CONTEXT:  referenced column: to_char
    
  • to_char(int, text)

    Description: Converts the values of the integer type into the strings in the specified format.

    Return type: text

    Example:

    openGauss=# SELECT to_char(125, '999');
     to_char
    ---------
      125
    (1 row)
    
  • to_char(set)

    Description: Converts a value of the SET type to a string.

    Return value: text

    Example:

    -- The site column is of the SET type in the employee table.
    openGauss=# select to_char(site) from employee;
         to_char     
    -----------------
     beijing,nanjing
     beijing,wuhan
    (2 rows)
    
  • to_char(numeric, text)

    Description: Converts the values of the numeric type into the strings in the specified format.

    Return type: text

    Example:

    openGauss=# SELECT to_char(-125.8, '999D99S');
     to_char
    ---------
     125.80-
    (1 row)
    
  • to_char(string)

    Description: Converts the CHAR/VARCHAR/VARCHAR2/CLOB type into the VARCHAR type.

    If this function is used to convert data of the CLOB type, and the value to be converted exceeds the value range of the target type, an error is returned.

    Return type: varchar

    Example:

    openGauss=# SELECT to_char('01110');
     to_char
    ---------
     01110
    (1 row)
    
  • to_char(timestamp, text)

    Description: Converts the values of the timestamp type into the strings in the specified format.

    Return type: text

    Example:

    openGauss=# SELECT to_char(current_timestamp, 'HH12:MI:SS');
     to_char
    ----------
     10:55:59
    (1 row)
    
  • to_char(blob, [CSID])

    Description: Only on dbcompatibility = 'A' support the function,convert blob type data to text by specified CSID.

    • CSID type is int,denote A format character ID.
    • CSID equal to 0 or without CSID, use database's encoding.

    CSID map to encoding name

    CSIDencoding nameopenGuass name
    1US7ASCIISQL_ASCII
    837JA16EUCTILDEEUC_JP
    850ZHS16CGB231280EUC_CN
    846KO16MSWIN949EUC_KR
    862ZHT16DBTEUC_TW
    830JA16EUCEUC_JIS_2004
    852ZHS16GBKGBK
    873AL32UTF8UTF8
    31WE8ISO8859P1LATIN1
    32EE8ISO8859P2LATIN2
    33SE8ISO8859P3LATIN3
    34NEE8ISO8859P4LATIN4
    39WE8ISO8859P9LATIN5
    40NE8ISO8859P10LATIN6
    47BLT8ISO8859P13LATIN7
    48CEL8ISO8859P14LATIN8
    46WE8ISO8859P15LATIN9
    560AR8MSWIN1256WIN1256
    45VN8MSWIN1258WIN1258
    41TH8TISASCIIWIN874
    196CL8KOI8RKOI8R
    171CL8MSWIN1251WIN1251
    178WE8MSWIN1252WIN1252
    35CL8ISO8859P5ISO_8859_5
    36AR8ISO8859P6ISO_8859_6
    37EL8ISO8859P7ISO_8859_7
    38IW8ISO8859P8ISO_8859_8
    170EE8MSWIN1250WIN1250
    173BG8MSWINWIN1253
    177TR8MSWIN1254WIN1254
    175IW8MSWIN1255WIN1255
    179BLT8MSWIN1257WIN1257
    51CL8KOI8UKOI8U
    854ZHS32GB18030GB18030
    832JA16SJISSJIS
    865ZHT16BIG5BIG5

    Return type: text

    Example:

    CREATE TABLE blob_table (c1 BLOB);
    INSERT INTO blob_table (c1) VALUES ( (encode('Hello World!','hex'))::RAW );
    SELECT to_char(c1, 873) FROM blob_table ;
       to_char    
    --------------
     Hello World!
    (1 row)
    
    SELECT to_char(c1) FROM blob_table ;
       to_char    
    --------------
     Hello World!
    (1 row)
    

-   to\_clob\(char/nchar/varchar/varchar2/nvarchar/nvarchar2/text/raw\)

  Description: Converts the raw type or text character set type CHAR, NCHAR, VARCHAR, VARCHAR2, NVARCHAR, NVARCHAR2, or TEXT to the CLOB type.

  Return type: clob

  Example:

  ```
  openGauss=# SELECT to_clob('ABCDEF'::RAW(10));
   to_clob 
  ---------
   ABCDEF
  (1 row)
  ```

  ```
  openGauss=# SELECT to_clob('hello111'::CHAR(15));
   to_clob  
  ----------
   hello111
  (1 row)
  ```

  ```
  openGauss=# SELECT to_clob('gauss123'::NCHAR(10));
   to_clob  
  ----------
   gauss123
  (1 row)
  ```

  ```
  openGauss=# SELECT to_clob('gauss234'::VARCHAR(10));
   to_clob  
  ----------
   gauss234
  (1 row)
  ```

  ```
  openGauss=# SELECT to_clob('gauss345'::VARCHAR2(10));
   to_clob  
  ----------
   gauss345
  (1 row)
  ```

  ```
  openGauss=# SELECT to_clob('gauss456'::NVARCHAR2(10));
   to_clob  
  ----------
   gauss456
  (1 row)
  ```

  ```
  openGauss=# SELECT to_clob('World222!'::TEXT);
    to_clob  
  -----------
   World222!
  (1 row)
  ```

-   to\_date\(text\)

  Description: Converts values of the text type into the timestamp in the specified format. Currently, only the following two formats are supported:

  -   Format 1: Date without separators, for example, 20150814. The value must contain the complete year, month, and day.
  -   Format 2: Date with separators, for example, 2014-08-14. The separator can be any non-digit character.

  Return type: timestamp without time zone

  Example:

  ```
  openGauss=# SELECT to_date('2015-08-14');
         to_date
  ---------------------
   2015-08-14 00:00:00
  (1 row)
  ```

-   to\_date\(text, text\)

  Description: Converts the values of the string type into the dates in the specified format.

  Return type: timestamp without time zone

  Example:

  ```
  openGauss=# SELECT to_date('05 Dec 2000', 'DD Mon YYYY');
         to_date
  ---------------------
   2000-12-05 00:00:00
  (1 row)
  ```

- to\_number ( expr \[ DEFAULT return_value ON CONVERSION ERROR ] [, fmt])

  Description: Converts expr to a NUMERIC type value according to the specified format. If the expr conversion fails, it will attempt to convert the return_value after the keyword DEFAULT (the input format of return_value is constrained by fmt).
  
  * Type Conversion Formats (fmt): Please refer to [Table 1](#en-us_topic_0283137417_en-us_topic_0237121973_en-us_topic_0059778246_t3987a5bb00154b0f9e55863b4ababd3d).

  * The length of the integer part in fmt must be greater than the length of the integer part in expr. If it is less, an error will be thrown. The length of the fractional part in fmt can be filled as needed, and the result will be truncated according to the length of the fractional part in fmt.

  * Both expr and the return_value after DEFAULT support implicit conversion. (Note: NULL plus any value equals NULL.)

  * Scientific notation is supported.

  * When converting a hexadecimal string to a decimal number, the function supports up to 16 bytes of hexadecimal string to be converted into an unsigned number.

  * When converting a hexadecimal string to a decimal number, the format string should not contain any characters other than 'x' or 'X', otherwise, an error will be thrown.

  Return type: numeric

  Example:

  ```
  openGauss=# SELECT to_number('12,454.8-', '99G999D9S');
   to_number 
  -----------
    -12454.8
  (1 row)
  ```
  ```
  openGauss=# SELECT to_number('1234.123','999999.99');
   to_number 
  -----------
     1234.12
  (1 row)
  ```
  ```
  openGauss=# SELECT to_number('111111.111'+'1111','999999.99');
   to_number 
  -----------
   112222.11
  (1 row)
  ```
  ```
  openGauss=# SELECT to_number('1e5'+'1111','999999.99');
   to_number 
  -----------
      101111
  (1 row)
  ```
  ```
  openGauss=# SELECT to_number('111111.111'+'1111'+NULL,'999999.  99');
   to_number 
  -----------        
  (1 row)
  ```
  ```
  openGauss=# SELECT to_number('此参数错误' default 321456231 on conversion error ,'999,999,999,999.99');
   to_number 
  -----------
   321456231
  (1 row)
  • to_timestamp(double precision)

    Description: Converts a UNIX century into a timestamp.

    Return type: timestamp with time zone

    Example:

    openGauss=# SELECT to_timestamp(1284352323);
          to_timestamp      
    ------------------------
     2010-09-13 12:32:03+08
    (1 row)
    
  • to_timestamp(string [ DEFAULT return_value ON CONVERSION ERROR ] [ , fmt [, 'nlsparam' ] ])

    Description: Converts a string to a timestamp. The default input format is [DD-Mon-YYYY HH12:MI:SS.FF], which is a 12-hour AM format. If the input value string is not in the default format, the user needs to specify their own format in fmt. If the format description is incorrect, an error will be thrown. If part of the string conversion fails, it will attempt to convert the return_value after the keyword DEFAULT (the input format of return_value is constrained by fmt). If Mon is an abbreviation like Jan, the language for the month can be set in nlsparam (currently only supports American and English).

    • If the input year YYYY=0, the system will throw an error.
    • If the input year YYYY<0, and SYYYY is specified in fmt, it will correctly output the absolute value of the year BC.
    • Parameters in fmt that are similar to MM cannot mix case.
    • The delimiters in fmt and the time information in string can be replaced with other symbols. Example: SELECT to_timestamp('05*Dec^2000', 'DD Mon+YYYY');

    Return type: timestamp with time zone

    Example:

    openGauss=# SHOW nls_timestamp_format;
        nls_timestamp_format    
    ----------------------------
     DD-Mon-YYYY HH:MI:SS.FF AM
    (1 row)
    
    openGauss=# SELECT to_timestamp('12-sep-2014');
        to_timestamp     
    ---------------------
     2014-09-12 00:00:00
    (1 row)
    
    openGauss=# SELECT to_timestamp ('01-Jan-2002 10:10:10.  123000');
        to_timestamp       
    -------------------------
     2002-01-01 10:10:10.123
    (1 row)
    
    openGauss=# SELECT to_timestamp ('2002-01-01 10:10:10.123000',  'YYYY-MM-DD HH24:MI:SS.FF');
          to_timestamp       
    -------------------------
     2002-01-01 10:10:10.123
    (1 row)
    
    openGauss=# SELECT to_timestamp ('此为错误输入' DEFAULT   '11-01-11 14:10:10.123000' ON CONVERSION ERROR,'DD-MM-RR   HH24:MI:SS.FF');
          to_timestamp       
    -------------------------
     2011-01-11 14:10:10.123
    (1 row)
    
    openGauss=# SELECT to_timestamp ('01-Jan-03 14:10:10.123000'   DEFAULT '11-Jan-11 14:10:10.123000' ON CONVERSION ERROR,  'DD-Mon-RR HH24:MI:SS.FF','NLS_DATE_LANGUAGE = American');
          to_timestamp       
    -------------------------
     2003-01-01 14:10:10.123
    (1 row)
    
    openGauss=# SELECT to_timestamp('-1','SYYYY');
          to_timestamp      
    ------------------------
     0001-01-01 00:00:00 BC
    (1 row)
    
    openGauss=# SELECT to_timestamp('05 Dec 2000', 'DD Mon YYYY');
        to_timestamp
    ---------------------
     2000-12-05 00:00:00
    (1 row)
    
    openGauss=# SELECT to_timestamp('05*Dec^2000', 'DD Mon+YYYY');
      to_timestamp     
    ---------------------
     2000-12-05 00:00:00
    (1 row)
    

Table 1 Template patterns for numeric formatting

Pattern

Description

9

Value with specified digits

0

Values with leading zeros

Period (.)

Decimal point

Comma (,)

Group (thousand) separator

PR

Negative values in angle brackets

S

Sign anchored to number (uses locale)

L

Currency symbol (uses locale)

D

Decimal point (uses locale)

G

Group separator (uses locale)

MI

Minus sign in the specified position (if the number is less than 0)

PL

Plus sign in the specified position (if the number is greater than 0)

SG

Plus or minus sign in the specified position

RN

Roman numerals (the input values are between 1 and 3999)

TH or th

Ordinal number suffix

V

Shifts specified number of digits (decimal)

  • abstime_text

    Description: Converts abstime to text.

    Parameter: abstime

    Return type: text

  • abstime_to_smalldatetime

    Description: Converts abstime to smalldatatime.

    Parameter: abstime

    Return type: smalldatetime

  • bigint_tid

    Description: Converts bigint to tid.

    Parameter: bigint

    Return type: tid

  • bool_int1

    Description: Converts bool to int1.

    Parameter: Boolean

    Return type: tinyint

  • bool_int2

    Description: Converts bool to int2.

    Parameter: Boolean

    Return type: smallint

  • bool_int8

    Description: Converts bool to int8.

    Parameter: Boolean

    Return type: bigint

  • bpchar_date

    Description: Converts a string to a date.

    Parameter: character

    Return type: date

  • bpchar_float4

    Description: Converts a string to float4.

    Parameter: character

    Return type: real

  • bpchar_float8

    Description: Converts a string to float8.

    Parameter: character

    Return type: double precision

  • bpchar_int4

    Description: Converts a string to int4.

    Parameter: character

    Return type: integer

  • bpchar_int8

    Description: Converts a string to int8.

    Parameter: character

    Return type: bigint

  • bpchar_numeric

    Description: Converts a string to numeric.

    Parameter: character

    Return type: numeric

  • bpchar_timestamp

    Description: Converts a string to a timestamp.

    Parameter: character

    Return type: timestamp without time zone

  • bpchar_to_smalldatetime

    Description: Converts a string to smalldatetime.

    Parameter: character

    Return type: smalldatetime

  • cupointer_bigint

    Description: Converts the column-store CU pointer type to the bigint type.

    Parameter: text

    Return type: bigint

  • date_bpchar

    Description: Converts the date type to bpchar.

    Parameter: date

    Return type: character

  • date_text

    Description: Converts date to text.

    Parameter: date

    Return type: text

  • date_varchar

    Description: Converts date to varchar.

    Parameter: date

    Return type: character varying

  • f4toi1

    Description: Forcibly converts float4 to uint8.

    Parameter: real

    Return type: tinyint

  • f8toi1

    Description: Forcibly converts float8 to uint8.

    Parameter: double precision

    Return type: tinyint

  • float4_bpchar

    Description: Converts float4 to bpchar.

    Parameter: real

    Return type: character

  • float4_text

    Description: Converts float4 to text.

    Parameter: real

    Return type: text

  • float4_varchar

    Description: Converts float4 to varchar.

    Parameter: real

    Return type: character varying

  • float8_bpchar

    Description: Converts float8 to bpchar.

    Parameter: double precision

    Return type: character

  • float8_interval

    Description: Converts float8 to interval.

    Parameter: double precision

    Return type: interval

  • float8_text

    Description: Converts float8 to text.

    Parameter: double precision

    Return type: text

  • float8_varchar

    Description: Converts float8 to varchar.

    Parameter: double precision

    Return type: character varying

  • i1tof4

    Description: Converts uint8 to float4.

    Parameter: tinyint

    Return type: real

  • i1tof8

    Description: Converts uint8 to float8.

    Parameter: tinyint

    Return type: double precision

  • i1toi2

    Description: Converts uint8 to int16.

    Parameter: tinyint

    Return type: smallint

  • i1toi4

    Description: Converts uint8 to int32.

    Parameter: tinyint

    Return type: integer

  • i1toi8

    Description: Converts uint8 to int64.

    Parameter: tinyint

    Return type: bigint

  • i2toi1

    Description: Converts int16 to uint8.

    Parameter: smallint

    Return type: tinyint

  • i4toi1

    Description: Converts int32 to uint8.

    Parameter: integer

    Return type: tinyint

  • i8toi1

    Description: Converts int64 to uint8.

    Parameter: bigint

    Return type: tinyint

  • int1_avg_accum

    Description: Adds the second parameter of the uint8 type to the first parameter. The first parameter is an array of the bigint type.

    Parameter: bigint[], tinyint

    Return type: bigint[]

  • int1_bool

    Description: Converts uint8 to bool.

    Parameter: tinyint

    Return type: Boolean

  • int1_bpchar

    Description: Converts uint8 to bpchar.

    Parameter: tinyint

    Return type: character

  • int1_mul_cash

    Description: Returns the product of a parameter of the int8 type and a parameter of the cash type. The return type is cash.

    Parameter: tinyint, money

    Return type: money

  • int1_numeric

    Description: Converts uint8 to numeric.

    Parameter: tinyint

    Return type: numeric

  • int1_nvarchar2

    Description: Converts uint8 to nvarchar2.

    Parameter: tinyint

    Return type: nvarchar2

  • int1_text

    Description: Converts uint8 to text.

    Parameter: tinyint

    Return type: text

  • int1_varchar

    Description: Converts uint8 to varchar.

    Parameter: tinyint

    Return type: character varying

  • int1in

    Description: Converts a string into an unsigned 1-byte integer.

    Parameter: cstring

    Return type: tinyint

  • int1out

    Description: Converts an unsigned 1-byte integer into a string.

    Parameter: tinyint

    Return type: cstring

  • int1up

    Description: Converts an input integer to an unsigned 1-byte integer.

    Parameter: tinyint

    Return type: tinyint

  • int2_bool

    Description: Converts a signed two-byte integer to the bool type.

    Parameter: smallint

    Return type: Boolean

  • int2_bpchar

    Description: Converts a signed two-byte integer to the bpchar type.

    Parameter: smallint

    Return type: character

  • int2_text

    Description: Converts a signed two-byte integer to the text type.

    Parameter: smallint

    Return type: text

  • int2_varchar

    Description: Converts a signed two-byte integer to the varchar type.

    Parameter: smallint

    Return type: character varying

  • int8_text

    Description: Converts an eight-byte signed integer to the text type.

    Parameter: bigint

    Return type: text

  • int8_varchar

    Description: Converts an eight-byte signed integer to varchar.

    Parameter: bigint

    Return type: character varying

  • intervaltonum

    Description: Converts the internal dats type date to numeric.

    Parameter: interval

    Return type: numeric

  • numeric_bpchar

    Description: Converts numeric to bpchar.

    Parameter: numeric

    Return type: character

  • numeric_int1

    Description: Converts numeric to a signed one-byte integer.

    Parameter: numeric

    Return type: tinyint

  • numeric_text

    Description: Converts numeric to text.

    Parameter: numeric

    Return type: text

  • numeric_varchar

    Description: Converts numeric to varchar.

    Parameter: numeric

    Return type: character varying

  • nvarchar2in

    Description: Converts c string to varchar.

    Parameter: cstring, oid, integer

    Return type: nvarchar2

  • nvarchar2out

    Description: Converts text into a c string.

    Parameter: nvarchar2

    Return type: cstring

  • nvarchar2send

    Description: Converts varchar to binary.

    Parameter: nvarchar2

    Return type: bytea

  • oidvectorin_extend

    Description: Converts a string to oidvector.

    Parameter: cstring

    Return type: oidvector_extend

  • oidvectorout_extend

    Description: Converts oidvector to a string.

    Parameter: oidvector_extend

    Return type: cstring

  • oidvectorsend_extend

    Description: Converts oidvector to a string.

    Parameter: oidvector_extend

    Return type: bytea

  • reltime_text

    Description: Converts reltime to text.

    Parameter: reltime

    Return type: text

  • text_date

    Description: Converts the text type to the date type.

    Parameter: text

    Return type: date

  • text_float4

    Description: Converts text to float4.

    Parameter: text

    Return type: real

  • text_float8

    Description: Converts the text type to float8.

    Parameter: text

    Return type: double precision

  • text_int1

    Description: Converts the text type to int1.

    Parameter: text

    Return type: tinyint

  • text_int2

    Description: Converts the text type to the int2 type.

    Parameter: text

    Return type: smallint

  • text_int4

    Description: Converts the text type to int4.

    Parameter: text

    Return type: integer

  • text_int8

    Description: Converts the text type to the int8 type.

    Parameter: text

    Return type: bigint

  • text_numeric

    Description: Converts the text type to the numeric type.

    Parameter: text

    Return type: numeric

  • text_timestamp

    Description: Converts the text type to the timestamp type.

    Parameter: text

    Return type: timestamp without time zone

  • time_text

    Description: Converts the time type to the text type.

    Parameter: time without time zone

    Return type: text

  • timestamp_text

    Description: Converts the timestamp type to the text type.

    Parameter: timestamp without time zone

    Return type: text

  • timestamp_to_smalldatetime

    Description: Converts the timestamp type to the smalldatetime type.

    Parameter: timestamp without time zone

    Return type: smalldatetime

  • timestamp_varchar

    Description: Converts the timestamp type to varchar.

    Parameter: timestamp without time zone

    Return type: character varying

  • timestamptz_to_smalldatetime

    Description: Converts timestamptz to smalldatetime.

    Parameter: timestamp with time zone

    Return type: smalldatetime

  • timestampzone_text

    Description: Converts the timestampzone type to the text type.

    Parameter: timestamp with time zone

    Return type: text

  • timetz_text

    Description: Converts the timetz type to the text type.

    Parameter: time with time zone

    Return type: text

  • to_integer

    Description: Converts data to the integer type.

    Parameter: character varying

    Return type: integer

  • to_interval

    Description: Converts to the interval type.

    Parameter: character varying

    Return type: interval

  • to_numeric

    Description: Converts to the numeric type.

    Parameter: character varying

    Return type: numeric

  • to_nvarchar2

    Description: Converts to the nvarchar2 type.

    Parameter: numeric

    Return type: nvarchar2

  • to_text

    Description: Converts to the text type.

    Parameter: smallint

    Return type: text

  • to_ts

    Description: Converts to the ts type.

    Parameter: character varying

    Return type: timestamp without time zone

  • to_varchar2

    Description: Converts to the varchar2 type.

    Parameter: timestamp without time zone

    Return type: character varying

  • varchar_date

    Description: Converts varchar to date.

    Parameter: character varying

    Return type: date

  • varchar_float4

    Description: Converts varchar to float4.

    Parameter: character varying

    Return type: real

  • varchar_float8

    Description: Converts the varchar type to the float8 type.

    Parameter: character varying

    Return type: double precision

  • varchar_int4

    Description: Converts the type from varchar to int4.

    Parameter: character varying

    Return type: integer

  • varchar_int8

    Description: Converts the varchar type to the int8 type.

    Parameter: character varying

    Return type: bigint

  • varchar_numeric

    Description: Converts varchar to numeric.

    Parameter: character varying

    Return type: numeric

  • varchar_timestamp

    Description: Converts varchar to timestamp.

    Parameter: character varying

    Return type: timestamp without time zone

  • varchar2_to_smlldatetime

    Description: Converts varchar2 to smlldatetime.

    Parameter: character varying

    Return type: smalldatetime

  • xidout4

    Description: The xid output is a four-byte number.

    Parameter: xid32

    Return type: cstring

  • xidsend4

    Description: Converts xid to the binary format.

    Parameter: xid32

    Return type: bytea

Encoding Type Conversion

  • convert_to_nocase(text, text)

    Description: Converts a string into a specified encoding type.

    Return type: bytea

    Example:

    openGauss=# SELECT convert_to_nocase('12345', 'GBK');
     convert_to_nocase 
    -------------------
     \x3132333435
    (1 row)
    
Feedback
编组 3备份
    openGauss 2025-07-15 22:42:49
    cancel