加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Postgresql 记事

发布时间:2020-12-13 17:40:38 所属栏目:百科 来源:网络整理
导读:Date:2012-12-13 Env:Postgresql 9.2,pgAdmin3 1.//字段包含大写时导致插入失败 创建表(从pgAdmin3截取): CREATE TABLE county( "provinceId" character(2) NOT NULL,"cityId" character(2) NOT NULL,"countyId" character(2) NOT NULL,"countyName" charact

Date:2012-12-13

Env:Postgresql 9.2,pgAdmin3

1.//字段包含大写时导致插入失败

创建表(从pgAdmin3截取):

CREATE TABLE county
(
  "provinceId" character(2) NOT NULL,"cityId" character(2) NOT NULL,"countyId" character(2) NOT NULL,"countyName" character varying(20) NOT NULL,CONSTRAINT cou_pk PRIMARY KEY ("provinceId","cityId","countyId")
)

执行sql:

INSERT INTO county (provinceId,cityId,countyId,countyName)  VALUES ('11','02','29','延庆县')

结果:pgAdmin3提示:错误: 关系 "county" 的 "provinceid" 字段不存在
SQL 状态: 42703

分析与修正:Postgresl字段或表名不加引号是不区分大小写,如果字段或表名有大小写就必须加引号.建议字段命名方式:xxx_xxx,用"_"分隔.

2.//pg保留前导零,效果类似mysql的int(M)

chenhao=> select to_char(1,'00');
 to_char 
---------
  01
(1 row)

3.//integer保存unix时间戳的2038bug

原因:32位的数从0-0xFFFFFFFF秒,大概到2038年unix时间戳将会溢出.Fix:使用bigint.

Postgre资料汇总

http://francs3.blog.163.com/blog/static/405767272014017341219/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读