TABLE ORGANIZE BY (Beitrag von Katalin Varnai)
- Dieses Thema hat 3 Antworten und 1 Teilnehmer, und wurde zuletzt aktualisiert vor 14 Jahre, 11 Monaten von
Anonym.
-
AuthorPosts
-
5. Oktober 2008 um 10:27 Uhr #3999
AnonymInaktiv[hr]
Beitrag im Namen von Katalin Varnai !!!
[hr]
Hallo Kollegen,eine Tabelle created mit ORGANIZE BY hat ein unique index und darf kein primary key gegeben werden (DB2 LUW V9). Die folgenden Versuche beweisen das:
CREATE T ABLE orgtest  (
  SZK_ID  BIGINT NOT NULL ,
  SZK_LASTUPD TIMESTAMP )
        ORGANIZE BY KEY SEQUENCE (SZK_ID STARTING 1 Â
                ENDING  7000) ALLOW OVERFLOW ; Â
alter t able orgtest add constraint p_szk_id primary key (szk_id);[highlight]SQL0541W Â The referential, primary key, or unique constraint "P_SZK_ID" is ignored because it is a duplicate constraint. Â SQLSTATE=01543[/highlight]
CREATE T ABLE orgtest  (
  SZK_ID  BIGINT NOT NULL PRIMARY KEY,
  SZK_LASTUPD TIMESTAMP )
        ORGANIZE BY KEY SEQUENCE (SZK_ID STARTING 1
                  ENDING  7000) ALLOW OVERFLOW ;[highlight]SQL0541W  The referential, primary key, or unique constraint "SZK_ID…" is ignored because it is a duplicate constraint.  SQLSTATE=01543[/highlight]
Ohne primary key funktioniert dann z.B. IMPORT… INSERT_UPDATE nicht (und was alles noch?).
Das bedeutet für mich, diese Tabelle wäre praktisch unbenutzbar, obwohl die Idee würde mir schon gefallen: Durch organize by key sequence Speicherung mit der Tabelle schneller arbeiten zu können !
Denke ich es falsch?
Mit freundlichen Grüßen
Katalin Varnai
8. Oktober 2008 um 19:13 Uhr #4173
AnonymInaktivHallo Katalin,
der Beweis war gar nicht zu führen, DB2 verhält sich vorschriftsmäßig und wie dokumentiert:
Specifies a column of the table that is included in the unique key that determines the sequence of the range-clustered table. … A unique index entry will automatically be created in the catalog for the columns in the key sequence specified with ascending order for each column.
(Siehe http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0000927.htm.)
Um welchen Aspekt geht es Dir? Wie sieht die Anforderung aus, die Du mit Hilfe von DB2/SQL lösen möchtest?
Wenn Du verschiedene Möglichkeiten betrachten möchtest, hilft Dir ein Blick ion Graeme Birchall’s "DB2 Cookbook", siehe http://www.google.de/url?sa=t&source=web&ct=res&cd=2&url=http%3A%2F%2Fmysite.verizon.net%2FGraeme_Birchall%2Fcookbook%2FDB2V91CK.PDF&ei=zQXtSMk_lczSBbTHud0M&usg=AFQjCNGS6xxtthRbgt50JW2IY6MUCG2rVQ&sig2=YMV2dE0a0WNoqCRtyapydQ.
Wir freuen uns auf Feedback von Dir!
Viele Grüße
Gernot
9. Oktober 2008 um 9:04 Uhr #4307
AnonymInaktivHi,
in den Erläuterungen zur zugehörigen DDL findet sich folgendes:
"A unique index entry will automatically be created in the catalog for the columns in the key sequence specified with ascending order for each column. The name of the index will be SQL, followed by a character timestamp (yymmddhhmmssxxx), with SYSIBM as the schema name. An actual index object is not created in storage, because the table organization is ordered by this key. If a primary key or a unique constraint is defined on the same columns as the range-clustered table sequence key, this same index entry is used for the constraint."
Für mich hört sich das so an, dass ein PK erlaubt ist und den bestehenden Index nutzt. Die Fehlermeldung von Katalin Varnai besagt aber, dass der PK ignoriert also nicht angelegt wird. Ist das eine Überinterpretation von mir oder ein Doku-Fehler von DB2?
MfG
AxelP
18. Oktober 2008 um 15:12 Uhr #4403
AnonymInaktivDanke für die Antwort-Gedanken Gernot und Axel,
und noch mal kurz zum Thema.
Mein Absicht und Ziel wäre mit ORGANIZE BY KEY SEQUENCE, dass die Recherchen schneller gingen. Irgendwo habe ich darüber gelesen, getestet habe ich es allerdings nicht.
Das Cookbook benutze ich auch manchmal, und finde das ein wertvolles, gutes Mittel, über range-clustered table steht darin jedoch kaum etwas.
Ein primary key kann ich – mindestens in meinen Versionen (WS V9 windows und Linux) – nicht createn, also der Satz, den Alex aus dem SQL Reference zitierte, stimmt so nicht. Ich wäre dankbar, wenn jemand einen Test in einem anderen System machen würde und darüber berichtete (also c reate table mit organize by key sequence und dazu noch primary key). Und wenn es tatsächlich nicht möglich ist, könnte man beim IBM darüber vielleicht nachfragen? Ich wäre gespannt auf die Antwort!
MfG
Katalin
-
AuthorPosts
You must be logged in to reply to this topic.