PostgreSQL类型转换
1.int装string
select CAST (1234 AS text)
select to_char(1234,’999‘)
2.string转int
select cast('999' as NUMERIC)
--5 附: PostgreSQL 类型转换函数
| Function | Return Type | Description | Example |
|---|---|---|---|
|
to_char ) |
text | convert time stamp to string | to_char(current_timestamp, 'HH12:MI:SS') |
|
to_char ( interval, text ) |
text | convert interval to string | to_char(interval '15h 2m 12s', 'HH24:MI:SS') |
|
to_char ( int, text ) |
text | convert integer to string | to_char(125, '999') |
|
to_char precision |
text | convert real/double precision to string | to_char(125.8::real, '999D9') |
|
to_char ( numeric, text ) |
text | convert numeric to string | to_char(-125.8, '999D99S') |
|
to_date (text, text ) |
date | convert string to date | to_date('05 Dec 2000', 'DD Mon YYYY') |
|
to_number ( text, text ) |
numeric | convert string to numeric | to_number('12,454.8-', '99G999D9S') |
|
to_timestamp ( text, text ) |
timestamp with time zone | convert string to time stamp | to_timestamp('05 Dec 2000', 'DD Mon YYYY') |
|
to_timestamp ( double precision ) |
timestamp with time zone | convert Unix epoch to time stamp | to_timestamp(1284352323) |
PostgreSQL类型转换的更多相关文章
- PostgreSQL 类型转换 -除法
PostgreSQL 类型转换 类似Oracle ,PostgreSQL也有强大的类型转换函数, 下面仅举两个类型转换例子. --1 例子 postgres=# select 1/4; ?colum ...
- PostgreSQL字段类型说明
BIGSERIALSERIAL8 存储自动递增的惟一整数,最多 8 字节. BIT 固定长度的位串. BIT VARYING(n)VARBIT(n) 可变长度的位串,长度为 n 位. BOOLEAN ...
- postgresql数据类型转换
PostgreSQL数据类型转换需要使用语法 alter table tbname alter column fieldname type date_type 遇到需要转换为特殊类型如DATE.BOO ...
- PostgreSQL 中日期类型转换与变量使用及相关问题
PostgreSQL中日期类型与字符串类型的转换方法 示例如下: postgres=# select current_date; date ------------ 2015-08-31 (1 row ...
- PostgreSQL 自定义自动类型转换(CAST)
转载自:https://yq.aliyun.com/articles/228271 背景 PostgreSQL是一个强类型数据库,因此你输入的变量.常量是什么类型,是强绑定的,例如 在调用操作符时,需 ...
- Mybatis使用自定义类型转换Postgresql
Mybatis使用自定义类型转换Postgresql 主要目的 为了解决从数据库取出来之后再手动转换为javaBean的问题. 主要用mybatis提供的Handler来把处理前置 添加转换类 imp ...
- postgreSQL数据类型转换字符串和数值
1.将数值转成字符串类型 方法1:调用to_char(int, text)函数,int为要转换值,text为数值格式化模式,其中模式描述为: 模式 描述 9 带有指定数值位数的值 0 带前导零的值 ...
- PostgreSQL数据库中的常见错误
转载以作参考. 错误1 FATAL: connection limit exceeded for non-superusers 原因:非超级用户的连接数(max_connections - super ...
- PostgreSQL笔记
本文针对目前最新版9.5.1,若非说明,文中所说文档即指官方文档.本人刚接触PostgreSQL不久,文中不免错漏,请大家指正:随着了解深入,本文[可能]会不定期更新补足. JSON PostgreS ...
随机推荐
- iOS $299刀企业证书申请的过程以及细节补充
最近申请了iOS的 299刀企业证书,相关过程有些问题,分享出来,以便后来人参考. 申请的过程我主要参考了别人以前的文章,链接如下: 1.https://developer.apple.com/cn/ ...
- 数组的一个强大函数splice,[增,删,改]
// var a = [1,2,3]; // a.splice(0); // console.log(a); >>[] // a.splice(1); // console.log(a); ...
- Greenplum测试环境部署
1.准备3台主机 本实例是部署实验环境,采用的是Citrix的虚拟化环境,分配了3台RHEL6.4的主机. |------|------| |Master|创建模板后,额外添加20G一块磁盘/dev/ ...
- Django之路由、模板和模型系统
一.路由系统 浏览器会自动给url后加一个"/" django会自动给路由的正则表达式前面加一个"/" django会给任何不带"/"结尾的 ...
- HBase相关
hadoop和hbase节点添加和单独重启 有时候hadoop或hbase集群运行时间久了后,某些节点就会失效,这个时候如果不想重启整个集群(这种情况在很多情况下已经不被允许),这个时候可以单独重启失 ...
- ES6笔记(7)-- Promise异步编程
系列文章 -- ES6笔记系列 很久很久以前,在做Node.js聊天室,使用MongoDB数据服务的时候就遇到了多重回调嵌套导致代码混乱的问题. JS异步编程有利有弊,Promise的出现,改善了这一 ...
- VUE2.0不可忽视的很多变化
今天使用webpack-sample初始一个vue-cli项目,在app.vue文件中添加了个钩子函数ready,可是ready内的事件一直不执行,检查了webpack文件和package.json也 ...
- C# 与 Java 中的枚举
C#代码: 利用扩展方法,扩展枚举功能 using System; using System.Collections.Generic; using System.Text; using System. ...
- 【要什么自行车】ASP.NET MVC4笔记01:Asp.net MVC 分页,采用 MvcPager 和CYQ.Data来分页
Control: ) { ; ; using (MAction action = new MAction("brain")) { MDataTable table = action ...
- R语言介绍
R语言简介 R语言是一种为统计计算和图形显示而设计的语言环境,是贝尔实验室(Bell Laboratories)的Rick Becker.John Chambers和Allan Wilks开发的S语言 ...