Postgresql reshape Field "integer out of range"

Source: Internet
Author: User
Tags postgresql


1. Background


Before the end of the day, the database has a temporary table cert_display_tmp used to do the interface display, the table data is from T_cert_sample, Ying said the data is incorrect, and then manually perform the update function, report an integer out of range.


2. Fault Analysis2.1 Table Structure Analysis
CREATE TABLE cert_display_tmp
(
  id integer NOT NULL DEFAULT nextval(‘cert_display_tmp2_id_seq‘::regclass),
  cert_id bigint,
  total_sample bigint NOT NULL DEFAULT 0,
  CONSTRAINT cert_display_tmp2_pkey PRIMARY KEY (id)
)


The ID field of the table is a short shape, and it is also a self-increment sequence that suspects that the problem appears in this place




2.2 Overall analysis

the range of integer types is (-2147483648 to +2147483647), and then look at the next sequence value is '2147483648', just over the range of integers.

postgres=#=> select nextval(‘cert_display_tmp2_id_seq‘);
  nextval  
------------
 2147483648
(1 row)



3, fault resolution


Change ID of the field type is bigint type, execute function again, no error, fault resolution.


ALTER TABLE CERT_DISPLAY_TMP ALTER COLUMN ID bigint



Appendix


650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/84/91/wKiom1eVZ3OwrUhxAACHTw_mQYY833.png-wh_500x0-wm_3 -wmp_4-s_1471917698.png "title=" reshape Field "alt=" Wkiom1evz3owruhxaachtw_mqyy833.png-wh_50 "/>



This article is from the "Stranger, End" blog, please be sure to keep this source http://molu2013.blog.51cto.com/2615175/1829524



Postgresql reshape Field "integer out of range"


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.