我的数据库是Postgres 8,我需要将数据类型转换为其他类型。这意味着,其中一种列数据类型是varchar
需要把它在select语句中用PostgresSELECT
声明为int
当前,java中如何获取字符串值并将其转换为int
。
发布于 2018-01-31 11:06:59
cast(varchar_col AS int) -- SQL standard
或
varchar_col::int -- Postgres syntax shorthand
这些语法变体是有效的(几乎)任何地方第二种例外:
还有两个变体:
int4(varchar_col) -- only works for some type names
int '123' -- must be an untyped, quoted string literal
https://stackoverflow.com/questions/-100007270
复制相似问题