Example: Capturing a Mix of DML and DDL Requests in XML Format Using BEGIN QUERY CAPTURE - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

You have created the following employee table in the user_1 database.

     CREATE TABLE user_1.employee (
       emp_code  INTEGER,
       emp_name  VARCHAR(30),
       dept_code INTEGER,
       salary    FLOAT);

Assume that employee is populated with 1 million rows and that you collect statistics on the dept_code column using the following request.

     COLLECT STATS COLUMN (dept_code) ON employee;

The following BEGIN QUERY CAPTURE request specifies the VERBOSE and DETAILED STATSUSAGE options and captures query plan data in the user_1_QCD query capture database.

     BEGIN QUERY CAPTURE
     WITH VERBOSE, DETAILED STATSUSAGE
     INTO user_1_QCD
     AS WORKLOAD wl_1;

This BEGIN QUERY CAPTURE request captures the Object, SQL, Step Details, Verbose EXPLAIN text, statistics details, and information on the statistics used and statistics recommendations for all the following requests.

     SELECT *
     FROM employee
     WHERE emp_code > 2;
     DELETE FROM employee
     WHERE emp_code = 10;
     UPDATE employee
     SET dept_code = 11
     WHERE emp_code = 11;
     CREATE TABLE dept (
       dept_code INTEGER,
       dept_name VARCHAR(30),
       manager   VARCHAR(30));
     INSERT DEPT(11, 'HR', 'JOHN');

An END QUERY CAPTURE request terminates the BEGIN QUERY CAPTURE mode.

     END QUERY CAPTURE;    /* ends the BEGIN QUERY CAPTURE mode */

The following SELECT request returns the query IDs of all the requests that were captured in the QUERY CAPTURE session.

     SELECT DISTINCT ID
     FROM user_1_QCD.Xmlqcd
     WHERE WorkLoadName = 'wl_1';