DB2 Data type conversions:
1. CAST ()
CAST (<expression> as <data_ type>[length])
2. CONVERT ()
CONVERT (<data_ type>[length], <expression> [, Style])
1) data_type The data type defined for the SQL Server system, the user-defined data type cannot be used here.
2) length is used to specify how long the data is, and the default value is 30.
3) converts a char or varchar type to an integer type such as int or samllint, and the result must be a numeric value with a plus or minus sign.
4) The text type is converted to char or varchar type up to 8,000 characters, that is, the char or varchar data type is the maximum length.
5) The data stored by the image type is converted to binary or varbinary type, up to a maximum of 8,000 characters.
6) Convert integer value to Money or smallmoney type, processed in the currency unit of the defined country, such as RMB, USD, GBP, etc.
7) A bit type conversion converts a non-0 value to 1 and is still stored as a bit type.
8) attempts to convert to a different length of data type will truncate the conversion value and display "+" after the value is converted to identify the truncation occurred.
9) Use the style option of the CONVERT () function to display the date and time in a different format. The style is the conversion style number that is provided by the SQL Server system when converting Datatime and smalldatetime data to strings, and different style numbers have different output formats.
Money is an integer integer----> Char char (Money)
char-------> Integer integer (Trim (char))
Money is double (8,2) Double----->char char (CAST (Money as Decimal (8,2)))
Char------->double cast (CAST (char (A.money as Decimal (8,2)) as decimal (8,2) as Double)
Money is decimal (8,2) decimal------->char Digits (Money)
Char------->decimal cast (Digits (Money) as decimal (8,2))
Money is a date date------>char char (Money)
char------>date Date (Trim (char))
Money for bigint bigint---->char char (money)
Char----->bigint cast (char (money) as bigint)
DB2 Data type Conversions