码迷,mamicode.com
首页 > 数据库 > 详细

SQL - 类型转换

时间:2019-11-30 13:56:17      阅读:80      评论:0      收藏:0      [点我收藏+]

标签:border   substring   char   style   spl   sql   str   --   pre   

类型转换

SELECT numeric ‘10‘ / numeric ‘3‘ AS col_1;                    -- PG语法
SELECT ‘10‘::numeric/‘3‘::numeric AS col_1;                    -- PG语法
SELECT CURRENT_DATE::varchar(20);                              -- PG语法

select cast(‘10‘ as numeric) / cast (‘3‘ as numeric) as col_1; -- 标准的SQL语法

-- cast 函数
select substring(cast(‘12345‘ as text), 3, 1);

SQL - 类型转换

标签:border   substring   char   style   spl   sql   str   --   pre   

原文地址:https://www.cnblogs.com/duchaoqun/p/11962007.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!