Development: abnormal collection issues related to DB2 table Creation

Source: Internet
Author: User
Tags db2 sql error sql error

Development: abnormal collection issues related to DB2 table Creation

Because the table creation statements may be different when using the DB2 database for the first time, the Manual table creation method is used to fill in fields one by one. Check the primary key and the Creation fails. Read the SQL statements generated by the system.

The SQL statement is as follows:

Create table front. SCORE_REVERSE
(
SERIAL_NO VARCHAR (50 ),
SECRET_KEY VARCHAR (50 ),
TRADEBOX_ID INTEGER (32 ),
REDUCE_POINT_TYPE VARCHAR (50 ),
Performance_point_reason VARCHAR (50 ),
Performance_time VARCHAR (50 ),
LOGIN_NAME VARCHAR (50 ),
COMMODITY_ID INTEGER (32 ),
COMMODITY_NUMBER VARCHAR (50 ),
Point integer (32 ),
CONTACT_NAME VARCHAR (50 ),
CONTACT_MOBILE_NO VARCHAR (50 ),
CONTACT_ADDRESS VARCHAR (50 ),
COMMODITY_TYPE VARCHAR (50 ),
REVERSE_TIME VARCHAR (50 ),
Primary key (SERIAL_NO ));

Two errors are prompted:

First exception: [CREATE-0 row (s), 0.000 secs] [Error Code:-104, SQL State: 42601] DB2 SQL Error: SQLCODE =-104, SQLSTATE = 42601, SQLERRMC = INTEGER; R (50 ),

Because I couldn't find the desired answer on the internet, I directly looked at the problem and found that the prompt SQLERRMC = INTEGER; R (50) is removed from the INTEGER length, and I changed INTEGER (32) to INTEGER. Problem Solving

Second exception: DB2 SQL Error: SQLCODE =-542, SQLSTATE = 42831, SQLERRMC = SERIAL_NO, DRIVER = 4.15.82

This makes me unable to find my mind. After searching, I found that when DB2 creates a primary key, its primary key SQL must be set not to null. That is to say, set it to: SERIAL_NO VARCHAR (50) not null, and the system generates no not null

Modify the SQL statement again and run OK again. The table is created.

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.