Getting ready

You need to connect to Teradata Database using SQLA or Studio. Now, let's create two tables and insert data into them:

/* Table 1 for outer query*/CREATE VOLATILE TABLE EMP_TBL1
(
EMP_ID INTEGER ,

EMP_NAME VARCHAR(25),

EMP_DEPT INTEGER

)
primary index(EMP_ID)
on commit preserve rows;

INSERT INTO EMP_TBL1 VALUES (1,'Rajesh',10);

INSERT INTO EMP_TBL1 VALUES (2,'Rob',11);

INSERT INTO EMP_TBL1 VALUES (3,'Joey',10);

INSERT INTO EMP_TBL1 VALUES (4,'Ross','21');

INSERT INTO EMP_TBL1 VALUES (5,'Rose','22');

Now, let's create table 2, which will be used for inner query:

CREATE VOLATILE TABLE DEPT_TBL2
(
DEPT_ID INTEGER,
DEPT_NAME VARCHAR(10),
DEPT_CNTRY VARCHAR(10)
)
PRIMARY INDEX(DEPT_ID, DEPT_CNTRY)
on commit preserve rows;

INSERT ...

Get Teradata Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.