Domanda

so I'm using the DB2 scripting from IBM i / System i (and old version where Collection is used instead of Schema)

and I noticed that its becoming tedious to having to keep typing

"select * from mycollectionName.whatever" for each table.

is there anyway I can select from multiple tables and have it display all the information in one big table?

example:

CREATE TABLE UMALIK8.ADULTS (
ADULT_NUM VARCHAR (10) NOT NULL CONSTRAINT UMALIK8.ADULTS_PK PRIMARY KEY,
ADULT_L_NAME CHAR (50) NOT NULL,
ADULT_F_NAME CHAR (50) NOT NULL,
RELATIONSHIP CHAR (30) NOT NULL,
STREET VARCHAR (50) NOT NULL,
APT_NUM VARCHAR (10),
CITY CHAR (50) NOT NULL,
POSTAL_CODE VARCHAR (6) NOT NULL,
HOMEPHONE VARCHAR (20) NOT NULL,
WORKPHONE VARCHAR (20));

CREATE TABLE UMALIK8.EMPLOYEE (
EMP_NUM VARCHAR (10) NOT NULL,
EMP_L_NAME CHAR (50) NOT NULL,
EMP_F_NAME CHAR (50) NOT NULL,
PAYRATE DECIMAL (10, 2) NOT NULL,
POSNCODE VARCHAR (10) NOT NULL,
HIREDATE DATE NOT NULL,
CONSTRAINT UMALIK8.EMPLOYEE_PK PRIMARY KEY (EMP_NUM),
CONSTRAINT UMALIK8.EMPLOYEE_FK FOREIGN KEY (POSNCODE)
REFERENCES UMALIK8.POSITION(POSNCODE));

I have these two tables, and I've created my Insert statement for them.

Now I want to select them and view them across a big table, instead of having to switch tabs (in Run Script from System i Navigator).

Is this possible? Is it better to make individual select statement for each table i create?

Would I do something along the lines of this?

Select * From umalik8.Adults, umalik8.Employee
    WHERE umalik8.Adults = umalik8.Employee

EDIT

Okay, so I kinda got lucky and tried this

SELECT TABLE_NAME 
    FROM UMALIK8.SYSTABLES;     


SELECT COLUMN_NAME, TABLE_NAME
    FROM UMALIK8.syscolumns;   

AND it almost worked...it shows me all the tables and all the columns in each tab, EXCEPT what was inserted (the record).

All help is greatly appreciated!

È stato utile?

Soluzione

Am not sure this is possible, but this tutorial about joins could be a good read.

Or this for your iSeries / IBM i edition of DB2.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top