Example: Capturing a Mix of DML and DDL Requests in XML Format Using BEGIN QUERY CAPTURE - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
ft:locale
en-US
ft:lastEdition
2021-07-27
dita:mapPath
spp1591731285373.ditamap
dita:ditavalPath
spp1591731285373.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

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';