Solved

SQL1476N   CREATE TABLE NOT LOGGED INITIALLY FAILS...

Posted on 2003-12-04
6
2,936 Views
Last Modified: 2007-12-19
iS THE REASON THIS FAILS ANYTHING TO DO with the fact my primary key
ends with nullable columns....
the second  create table works if just the tradegroup column is allowed to be nullable...
 


db2 => CREATE TABLE stg.tmp_aGR_TRADE
(
    AGREEMENT_ID     INTEGER                NOT NULL,
   AGREEMENT_TYPCD  INTEGER                NOT NULL,
   TRADE_CODE CHAR(4) ,
   TRADEgROUP CHAR(4) ,
   poSTCODE CHAR(4) ,
   risks integer not null,
 primary key (AGREEMENT_id,AGREEMENT_TYPCD,TRADE_CODE,postcode)
)
IN heapSPACE
    INDEX IN heapSPACE
NOT LOGGED INITIALLY;db2 (cont.) => db2 (cont.) => db2 (cont.) => db2 (cont.) =>
 db2 (cont.) => db2 (cont.) => db2 (cont.) => db2 (cont.) => db2 (cont.) => db2
(cont.) => db2 (cont.) => db2 (cont.) =>
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL1476N  The current transaction was rolled back because of error "-542".
SQLSTATE=40506
db2 => CREATE TABLE stg.tmp_aGR_TRADE
(
    AGREEMENT_ID     INTEGER                NOT NULL,
   AGREEMENT_TYPCD  INTEGER                NOT NULL,
   TRADE_CODE CHAR(4) NOT NULL,
   TRADEgROUP CHAR(4) ,
   poSTCODE CHAR(4) NOT NULL,
   risks integer not null,
 primary key (AGREEMENT_id,AGREEMENT_TYPCD,TRADE_CODE,postcode)
)
IN heapSPACE
    INDEX IN heapSPACE
NOT LOGGED INITIALLY;
db2 (cont.) => db2 (cont.) => db2 (cont.) => db2 (cont.) => db2 (cont.) => db2 (
cont.) => db2 (cont.) => db2 (cont.) => db2 (cont.) => db2 (cont.) => db2 (cont.
) => db2 (cont.) => DB20000I  The SQL command completed successfully.
db2 =>
0
Comment
Question by:Lowfatspread
  • 3
  • 2
6 Comments
 
LVL 50

Author Comment

by:Lowfatspread
ID: 9878386
sorry DB2 UDB 7.2 on UNIX

0
 
LVL 18

Accepted Solution

by:
BigSchmuh earned 250 total points
ID: 9888240
Yes, you can NOT define a primary (neither a unique) key on Nullable columns.
==> The expression "Col1 = NULL" is evaluated to NULL whatever Col1 is and no dbms is expected to work with Null values outside the scope of "Is Null" or "Is Not Null" operators (Which means that some dbms does this...MS-Jet or Oracle used to allow creation of Unique index on nullable columns but I think none will allow that on Primary key)

Anyway, why don't you create your Primary key on a SEQUENCE based column ?

Hope this helps.
0
 
LVL 50

Author Comment

by:Lowfatspread
ID: 9888525
yes thanks schmuh, it had been a late and frustrating night at that stage....

on os390 you can have unique where not null indexes...

my primary key is basically my business key...
this is a temporary table to enable me to gather some min/max information
prior to populating the final wharehouse tables during my ETL process...
its a 4 way join at this stage and i'm trying to minimise index requirements...    
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 18

Expert Comment

by:BigSchmuh
ID: 9891497
Creating new primary keys based on sequence may save huge time if you need to make this 4 col joins more than once.
0
 

Expert Comment

by:Zhousanbao
ID: 10014230
   Take advantange of performence, I do not advice to use sequence .Can we  change (trade_code char(4) not null ,poSTCODE CHAR(4) NOT NULL) to (trade_code smallint not null  ,poSTCODE smallint NOT NULL)?
    I think you can get good performence especially this table is a fact table.
    By the way, If you upgrade to db2 udb v8 ,you can use mdc table  to improve the performence.
   
0
 
LVL 50

Author Comment

by:Lowfatspread
ID: 10015341
v8 in my dreams ...

that 'll be 2006 at the earliest
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now