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

SQL Data Definition Language Syntax and Examples

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
jco1628111346878.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
mdr1472255012272
lifecycle
latest
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';