Resolve DB2 Database Modify field value/Insert data failed

Source: Internet
Author: User

There are no modifications in the Modify field, for the following reasons:

1. Is there a constraint on the field?

2. is the field value self-increasing?

3, is the table used, or is the association trigger?

In DB2, inserting the data process, the increase of the field is apt to appear recessive problem:

The code is as follows Copy Code

INSERT into LGLK. T_uum_dept (UUID, Dept_no, Dept_name, parent_id, IsLeaf, STATUS, Cjzid, Cjzssbmid, CJSJ) VALUES (' 402881f03e11768c013e118 7f22e0002 ', ' 402881f03e11768c013e1187f22e0003 ', ' Hangzhou Xia Cheng District Brigade ', ' 402881ea3d8ba15e013d8ba5b6370004 ',
' 1 ', ' 1 ', ' 402881e63d778f3b013d779029600001 ', ' 402881ea3d8ba15e013d8ba4ed7d0002 ', current timestamp);

If the first UUID field is the primary key, each insertion must be different, and unlike the original, the insertion fails, and if the field values are associated, the field values must be the same, otherwise there are hidden errors, such as the value of the UUID and the value of the dept_no.

The code is as follows Copy Code

In DB2, UPDATE

To modify the data type of a field:

The code is as follows Copy Code
Update student Set usersetateid= (select Usertstateid where userstate= ' activity ') where studentid= ' Sutdentid ' of selected rows

Suppose A, b two tables:

The code is as follows Copy Code

UPDATE A

SET a1= (SELECT B1 from B WHERE a.id = b.id)

Indicates that you want to update the A1 field for all rows of table A: The row that satisfies the where a.id = b.ID is updated a1=b1, and the A1 is updated for the row that does not meet the change criteria.

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.