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

Teradata Vantage™ SQL Data Definition Language Syntax and Examples

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-24
dita:mapPath
wkf1512081455740.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval

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