Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.1 » UltraLite - 数据库管理和参考 » UltraLite SQL 参考 » UltraLite SQL 元素 » UltraLite 中的数据类型

 

显式转换数据类型

UltraLite 允许使您使用 CAST 或 CONVERT 函数显式地请求数据类型转换。

注意

通常,自转换对操作没有影响。但是,自转换到 CHAR/VARCHAR、BINARY/VARBINARY 和 NUMERIC 不是空操作过程。

可以 CAST 或 CONVERT 大多数数据类型的组合,如下表所示。

能否转换取决于转换中使用的值。因为与值相关 列显示的值必须与新数据类型兼容,以避免生成特定类型的转换错误。例如:

  • 如果将 varchar "1234" 转换为 long,此转换会受到支持。但是,如果将 varchar "hello" 转换为 long,那么此转换会生成 SQLE_CONVERSION_ERROR 错误,因为 hello 并不是一个数字。

  • 如果将 long 1234 转换为 short,此转换会受到支持。但是,如果将 long 1000000 转换为 short,那么此转换会生成 SQLE_OVERFLOW_ERROR 错误,因为 1000000 超出了短整型值可容纳的数字范围。

始终 永不 与值相关
BINARY 或 VARBINARY

CHAR 或 VARCHAR

BINARY

LONG BINARY

BIT

TINYINT

SHORT INT

SIGNED SHORT

BIGINT

SIGNED BIG

LONG VARCHAR

REAL

TIME

TIMESTAMP

DOUBLE

DATE

NUMERIC

UID1

LONG BINARY

BINARY

LONG BINARY

BIT

CHAR 或 VARCHAR

LONG VARCHAR

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

SIGNED LONG

BIGINT

SIGNED BIG

REAL

DOUBLE

NUMERIC

DATE

TIME

TIMESTAMP

UID

N/A
BIT

CHAR 或 VARCHAR

BINARY

BIT

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

SIGNED LONG

BIGINT

REAL

SIGNED BIG

DOUBLE

NUMERIC

LONG VARCHAR

LONG BINARY

DATE

TIME

TIMESTAMP

UID

N/A
CHAR 或 VARCHAR

BINARY 或 VARBINARY

CHAR 或 VARCHAR

LONG VARCHAR

LONG BINARY

BIT

TINYINT

SIGNED SHORT

SHORT INT

LONG INT

SIGNED LONG

BIGINT

SIGNED BIG

DOUBLE

NUMERIC

REAL

DATE

TIME

TIMESTAMP

UID

LONG VARCHAR

CHAR 或 VARCHAR

LONG VARCHAR

BINARY 或 VARBINARY

LONG BINARY

BIT

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

SIGNED LONG

BIGINT

SIGNED BIG

REAL

NUMERIC

DATE

TIME

TIMESTAMP

DOUBLE

UID

TINYINT

BINARY 或 VARBINARY

CHAR 或 VARCHAR

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

SIGNED LONG

BIGINT

SIGNED BIG

REAL

DOUBLE

NUMERIC

LONG VARCHAR

LONG BINARY

DATE

TIME

TIMESTAMP

UID

SHORT INT

BINARY 或 VARBINARY

CHAR 或 VARCHAR

SHORT INT

LONG INT

SIGNED LONG

BIGINT

SIGNED BIG

REAL

DOUBLE

NUMERIC

LONG VARCHAR

LONG BINARY

DATE

TIME

TIMESTAMP

UID

BIT

TINYINT

SIGNED SHORT

SIGNED SHORT

BINARY 或 VARBINARY

CHAR 或 VARCHAR

SIGNED SHORT

SIGNED LONG

SIGNED BIG

REAL

DOUBLE

NUMERIC

LONG VARCHAR

LONG BINARY

DATE

TIME

TIMESTAMP

UID

SHORT INT

LONG INT

BIGINT

BIT

TINYINT

LONG INT

BINARY 或 VARBINARY

CHAR 或 VARCHAR

LONG INT

BIGINT

SIGNED BIG

REAL

DOUBLE

NUMERIC

LONG VARCHAR

LONG BINARY

DATE

TIME

TIMESTAMP

UID

BIT

TINYINT

SHORT INT

SIGNED SHORT

SIGNED LONG

SIGNED LONG

BINARY 或 VARBINARY

CHAR 或 VARCHAR

SIGNED LONG

SIGNED BIG

REAL

DOUBLE

NUMERIC

DATE

TIMESTAMP

LONG VARCHAR

LONG BINARY

TIME

UID

BIT

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

BIGINT

BIGINT

BINARY 或 VARBINARY

CHAR 或 VARCHAR

BIGINT

REAL

DOUBLE

NUMERIC

LONG VARCHAR

LONG BINARY

DATE

TIME

TIMESTAMP

UID

BIT

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

SIGNED LONG

SIGNED BIG

SIGNED BIG

BINARY 或 VARBINARY

CHAR 或 VARCHAR

SIGNED BIG

REAL

DOUBLE

NUMERIC

DATE

TIMESTAMP

LONG VARCHAR

LONG BINARY

TIME

UID

BIT

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

SIGNED LONG

BIGINT

REAL

CHAR 或 VARCHAR

REAL

DOUBLE

NUMERIC

LONG VARCHAR

BINARY 或 VARBINARY

LONG BINARY

DATE

TIME

TIMESTAMP

UID

BIT

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

SIGNED LONG

BIGINT

SIGNED BIG

DOUBLE

CHAR 或 VARCHAR

DOUBLE

NUMERIC

LONG VARCHAR

BINARY 或 VARBINARY

LONG BINARY

DATE

TIME

TIMESTAMP

UID

BIT

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

SIGNED LONG

BIGINT

SIGNED BIG

REAL

NUMERIC

CHAR 或 VARCHAR

REAL

NUMERIC

DOUBLE

LONG VARCHAR

LONG BINARY

DATE

TIME

TIMESTAMP

UID

BINARY 或 VARBINARY2

BIT

SHORT INT

SIGNED SHORT

LONG INT

SIGNED LONG

BIGINT

SIGNED BIG

TINYINT

DATE

CHAR 或 VARCHAR

SIGNED LONG

SIGNED BIG

DATE

TIMESTAMP

LONG VARCHAR

LONG BINARY

BIT

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

BIGINT

REAL

DOUBLE

NUMERIC

TIME

BINARY 或 VARBINARY

UID

TIME

CHAR 或 VARCHAR

TIME

TIMESTAMP

LONG VARCHAR

LONG BINARY

BIT

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

SIGNED LONG

BIGINT

SIGNED BIG

REAL

DOUBLE

NUMERIC

DATE

BINARY 或 VARBINARY

UID

TIMESTAMP

CHAR 或 VARCHAR

SIGNED LONG

SIGNED BIG

DATE

TIME

TIMESTAMP

LONG VARCHAR

LONG BINARY

BIT

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

BIGINT

REAL

DOUBLE

NUMERIC

BINARY 或 VARBINARY

UID

UID

CHAR 或 VARCHAR

UID

LONG VARCHAR

LONG BINARY

BIT

TINYINT

SHORT INT

SIGNED SHORT

LONG INT

SIGNED LONG

BIGINT

SIGNED BIG

REAL

DOUBLE

NUMERIC

DATE

TIME

TIMESTAMP

BINARY 或 VARBINARY1

1 BINARY 值的长度必须为 16 字节,以便与 UUID 兼容。

2 仅当源 NUMERIC 值能够转换为 BIGINT 时才适用。