DB2

From no name for this wiki
Revision as of 21:07, 7 July 2008 by Claude (talk | contribs) (m)
Jump to: navigation, search

DB2 z/OS Stuff.

BLOBS, CLOBS

So kreiert man die auxiliary Tables automatisch. Das Zauberwort ist STD.

SET CURRENT SQLID = 'MYSCHEMA';
set current rules='STD';
Create table MYSCHEMA.MYTABLE (
   ID              DECIMAL(10,0)       NOT NULL    Generated Always
	 as identity (start with 1, increment by 1, cache 20),
   DATEI                          BLOB(1048576)                  With Default
) 
in MYSCHEMA.MYTABLESPACE ;

ALTER TABLE

Feld vergrössern

alter table MYSCHEMA.MYTABLE alter column MYCOLUMN set DATA TYPE CHAR(8);

Feld hinzufügen

 alter table MYSCHEMA.MYTABLE add column MYCOLUMN CHAR(6);

SQL

Count

Im DB2 ist die Kolonnenwahl mit count limitiert. Hier der Workaround:

SELECT T2.COLUMN1,  FROM  S983EM2.T_ZUWEISUNG AS T1, 
                          (Select OSTE_ID AS COLUMN1, count(OSTE_ID) AS COLUMN2 
                           from S983EM2.T_ZUWEISUNG group by OSTE_ID) AS T2 
WHERE T1.OSTE_ID = T2.COLUMN1;