Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL1476N   CREATE TABLE NOT LOGGED INITIALLY FAILS...

Posted on 2003-12-04
6
Medium Priority
?
3,015 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 1000 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

926 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