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.