Download Teradata Database-to-Teradata Aster User Guide

Document related concepts

Oracle Database wikipedia , lookup

Microsoft Access wikipedia , lookup

Concurrency control wikipedia , lookup

SQL wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Database wikipedia , lookup

Team Foundation Server wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Functional Database Model wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Ingres (database) wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Clusterpoint wikipedia , lookup

Relational model wikipedia , lookup

Versant Object Database wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Database model wikipedia , lookup

Transcript
What would you do if you knew?™
Teradata QueryGrid
Teradata Database-to-Teradata Aster
User Guide
Release 15.00.00
B035-1187-015K
February 2016
The product or products described in this book are licensed products of Teradata Corporation or its affiliates.
Teradata, Active Data Warehousing, Active Enterprise Intelligence, Applications-Within, Aprimo Marketing Studio, Aster, BYNET, Claraview,
DecisionCast, Gridscale, MyCommerce, QueryGrid, SQL-MapReduce, Teradata Decision Experts, "Teradata Labs" logo, Teradata
ServiceConnect, Teradata Source Experts, WebAnalyst, and Xkoto are trademarks or registered trademarks of Teradata Corporation or its
affiliates in the United States and other countries.
Adaptec and SCSISelect are trademarks or registered trademarks of Adaptec, Inc.
AMD Opteron and Opteron are trademarks of Advanced Micro Devices, Inc.
Apache, Apache Avro, Apache Hadoop, Apache Hive, Hadoop, and the yellow elephant logo are either registered trademarks or trademarks of the
Apache Software Foundation in the United States and/or other countries.
Apple, Mac, and OS X all are registered trademarks of Apple Inc.
Axeda is a registered trademark of Axeda Corporation. Axeda Agents, Axeda Applications, Axeda Policy Manager, Axeda Enterprise, Axeda
Access, Axeda Software Management, Axeda Service, Axeda ServiceLink, and Firewall-Friendly are trademarks and Maximum Results and
Maximum Support are servicemarks of Axeda Corporation.
Data Domain, EMC, PowerPath, SRDF, and Symmetrix are registered trademarks of EMC Corporation.
GoldenGate is a trademark of Oracle.
Hewlett-Packard and HP are registered trademarks of Hewlett-Packard Company.
Hortonworks, the Hortonworks logo and other Hortonworks trademarks are trademarks of Hortonworks Inc. in the United States and other
countries.
Intel, Pentium, and XEON are registered trademarks of Intel Corporation.
IBM, CICS, RACF, Tivoli, and z/OS are registered trademarks of International Business Machines Corporation.
Linux is a registered trademark of Linus Torvalds.
LSI is a registered trademark of LSI Corporation.
Microsoft, Active Directory, Windows, Windows NT, and Windows Server are registered trademarks of Microsoft Corporation in the United
States and other countries.
NetVault is a trademark or registered trademark of Dell Inc. in the United States and/or other countries.
Novell and SUSE are registered trademarks of Novell, Inc., in the United States and other countries.
Oracle, Java, and Solaris are registered trademarks of Oracle and/or its affiliates.
QLogic and SANbox are trademarks or registered trademarks of QLogic Corporation.
Quantum and the Quantum logo are trademarks of Quantum Corporation, registered in the U.S.A. and other countries.
Red Hat is a trademark of Red Hat, Inc., registered in the U.S. and other countries. Used under license.
SAP is the trademark or registered trademark of SAP AG in Germany and in several other countries.
SAS and SAS/C are trademarks or registered trademarks of SAS Institute Inc.
Simba, the Simba logo, SimbaEngine, SimbaEngine C/S, SimbaExpress and SimbaLib are registered trademarks of Simba Technologies Inc.
SPARC is a registered trademark of SPARC International, Inc.
Symantec, NetBackup, and VERITAS are trademarks or registered trademarks of Symantec Corporation or its affiliates in the United States and
other countries.
Unicode is a registered trademark of Unicode, Inc. in the United States and other countries.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Other product and company names mentioned herein may be the trademarks of their respective owners.
The information contained in this document is provided on an "as-is" basis, without warranty of any kind, either express or implied,
including the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. Some jurisdictions do not allow
the exclusion of implied warranties, so the above exclusion may not apply to you. In no event will Teradata Corporation be liable for any
indirect, direct, special, incidental, or consequential damages, including lost profits or lost savings, even if expressly advised of the
possibility of such damages.
The information contained in this document may contain references or cross-references to features, functions, products, or services that are not
announced or available in your country. Such references do not imply that Teradata Corporation intends to announce such features, functions,
products, or services in your country. Please consult your local Teradata Corporation representative for those features, functions, products, or
services available in your country.
Information contained in this document may contain technical inaccuracies or typographical errors. Information may be changed or updated
without notice. Teradata Corporation may also make improvements or changes in the products or services described in this information at any
time without notice.
To maintain the quality of our products and services, we would like your comments on the accuracy, clarity, organization, and value of this
document. Please e-mail: [email protected]
Any comments or materials (collectively referred to as "Feedback") sent to Teradata Corporation will be deemed non-confidential. Teradata
Corporation will have no obligation of any kind with respect to Feedback and will be free to use, reproduce, disclose, exhibit, display, transform,
create derivative works of, and distribute the Feedback and derivative works thereof without limitation on a royalty-free basis. Further, Teradata
Corporation will be free to use any ideas, concepts, know-how, or techniques contained in such Feedback for any purpose whatsoever, including
developing, manufacturing, or marketing products or services incorporating Feedback.
Copyright © 2016 by Teradata. All Rights Reserved.
Preface
Purpose
This book describes the Teradata® QueryGrid™: Teradata Database-to-Teradata Aster
Database SQL interface for transferring data between Teradata Database and remote
Teradata Aster Database hosts.
Use this book with the other books in the SQL book set.
Audience
This book is intended for database administrators and other technical personnel who use
Teradata Database.
Supported Releases
For Teradata QueryGrid supported releases information, see KAP314E23E.
Prerequisites
You should be familiar with basic relational database management theory and technology.
To become familiar with concepts specific to Teradata Database, read Introduction to
Teradata and SQL Fundamentals.
Changes to This Book
Release
Description
Teradata Teradata
QueryGrid: Teradata
Aster Database-toTeradata Database
15.00.00
Initial publication.
February 2016
Teradata Database-to-Teradata Aster
3
Preface
Additional Information
Additional Information
URL
Description
www.info.teradata.com
Use the Teradata Information Products Publishing Library site to:
• View or download a manual:
• Under Online Publications, select General Search.
• Enter your search criteria and click Search.
• Download a documentation CD-ROM:
• Under Online Publications, select General Search.
• In the Title or Keyword field, enter CD-ROM, and click Search.
www.teradata.com
The Teradata home page provides links to numerous sources of
information about Teradata. Links include:
• Executive reports, white papers, case studies of customer
experiences with Teradata, and thought leadership
• Technical information, solutions, and expert advice
• Press releases, mentions and media resources
www.teradata.com/TEN/
Teradata Customer Education delivers training that builds skills and
capabilities for our customers, enabling them to maximize their
Teradata investment.
https://tays.teradata.com
Use Teradata @ Your Service to access Orange Books, technical alerts,
and knowledge repositories, view and join forums, and download
software patches.
Teradata Developer
Exchange
Teradata Developer Exchange provides articles on using Teradata
products, technical discussion forums, and code downloads.
To maintain the quality of our products and services, we would like your comments on the
accuracy, clarity, organization, and value of this document. Please email [email protected].
Product Safety Information
This document may contain information addressing product safety practices related to data
or property damage, identified by the word Notice. A notice indicates a situation which, if not
avoided, could result in damage to property, such as equipment or data, but not related to
personal injury.
Example
Notice: Improper use of the Reconfiguration utility can result in data loss.
4
Teradata Database-to-Teradata Aster
CHAPTER 1
Introduction to Teradata QueryGrid: Teradata
Database-to-Teradata Aster Database
Overview of the Teradata-to-Aster Connector
Teradata QueryGrid: Teradata Database-to-Teradata Aster Database (also referred to as the
Teradata-to-Aster connector) provides an SQL interface for transferring data between
Teradata Database and remote Teradata Aster Database hosts. It allows you to do the
following:
• Create a remote server object that consists of a server name and the name/value pairs
that Teradata Database needs to connect to the remote Teradata Aster Database server.
• Associate an import operator and an export operator with the foreign server.
• Execute a variety of remote Aster analytical functions from Teradata on remote Aster
data or data exported from a local Teradata Database system.
• Import Teradata Aster Database data into a temporary or permanent Teradata Database
table.
• Export data from temporary or permanent Teradata Database tables into existing
Teradata Aster Database tables.
• Reference tables on the remote Teradata Aster Database hosts in SELECT and INSERT
statements.
• Limit the number of columns and rows that you import or export to control the amount
of data and enhance performance.
Considerations
You may not use this feature without the appropriate license. The fact that this feature may
be included in product media or downloads, or described in documentation that you receive
does not authorize you to use it without the appropriate license. Contact your Teradata sales
representative to purchase and enable this feature.
For Teradata QueryGrid supported releases information, see KAP314E23E.
The port on the Teradata system must be accessible. The default port for the Teradata-toAster connector is 5001. If you run any other application that listens on port 5001, you must
specify a different port number in the CREATE or ALTER FOREIGN SERVER statement.
All Teradata nodes must be connected on a network that is connected to all Queen and
Worker Bee nodes on the Teradata Aster system.
You must have a proxy user configured on the Teradata Aster Database.
Teradata Database-to-Teradata Aster
5
Chapter 1 Introduction to Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Overview of the Teradata-to-Aster Connector
Limitations
• ORDER BY clauses are not supported when you use SELECT with a FOREIGN TABLE.
To work around this limitation, you can order the results after they are returned to the
local system.
• Not all of the Teradata Aster analytic functions are supported.
For a list of the Teradata Aster analytic functions that the Teradata-to-Aster connector
supports, see Supported Aster Functions.
• Transaction semantics are not supported between the Teradata system and the Teradata
Aster system.
For example, suppose that the following statements are executed in this order:
1.
2.
3.
4.
BEGIN Transaction ;
INSERT INTO t1@remote SELECT * FROM local
INSERT INTO local values (1,2)
END Transaction ;
If the second statement fails, then the data that is being inserted into table t1 is rolled back
if it has not been committed by the local system. Once it is committed by the local system,
a late arriving abort does not roll back the data.
If an error occurs on the third statement, the data in the remote system is not rolled back.
It is already committed from the remote system’s perspective.
6
Teradata Database-to-Teradata Aster
CHAPTER 2
Getting Started with Teradata QueryGrid:
Teradata Database-to-Teradata Aster Database
Setup Tasks Needed to Use the Teradata-to-Aster
Connector
To prepare to use the Teradata-to-Aster connector, you need to become familiar with the
software. You then need to perform several tasks on the Teradata system and on the remote
Teradata Aster system.
Routines Used in the Teradata-to-Aster Connector
You should be familiar with the functions and procedures that the Teradata-to-Aster
connector uses, as you need to grant privileges on them to users so that they can create
foreign server objects or query a foreign server.
The Teradata-to-Aster connector provides the following routines:
Operator
Description
LOAD_FROM_ASTER
A table operator that is used to import data from a remote
Teradata Aster Database.
LOAD_TO_ASTER
A table operator that is used to export data to a remote Teradata
Aster Database.
ASTEREXECUTE
A table operator that is used to export data from a Teradata
Database system to a Teradata Aster server, execute a remote
function, and return the results.
For information about ASTEREXECUTE, see AsterExecute.
ExecuteForeignSQL
A stored procedure that is used to execute basic SQL queries,
such as CREATE, DROP, DELETE, and GRANT on a foreign
server.
For information about ExecuteForeignSQL, see
ExecuteForeignSQL.
EFSSPOP_TDSQLA
Teradata Database-to-Teradata Aster
A table operator that is used when you create a foreign server
object so that you can use the ExecuteForeignSQL syntax to run
SQL queries on the remote Teradata Aster server.
7
Chapter 2 Getting Started with Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Setup Tasks Needed to Use the Teradata-to-Aster Connector
Operator
Description
LOAD_FROM_REMOTE_TD
An internal routine that is installed on the Teradata Aster server
to import the data that is exported from the Teradata Database
system. You do not call the LOAD_FROM_REMOTE_TD
operator directly.
LOAD_TO_REMOTE_TD
An internal routine that is installed on the Teradata Aster server
to export data back to the Teradata Database system. You do not
call the LOAD_TO_REMOTE_TD operator directly.
Tasks To Be Performed On the Teradata System
• A Teradata DBA with the appropriate privileges needs to grant the following privileges to
the DBAs and users who are going to create foreign server objects:
• CREATE SERVER and DROP SERVER privileges on TD_SERVER_DB
• EXECUTE FUNCTION and SELECT privileges on LOAD_FROM_ASTER or on the
SYSLIB database
• EXECUTE FUNCTION and SELECT privileges on LOAD_TO_ASTER or on the
SYSLIB database
• EXECUTE FUNCTION and SELECT privileges on EFSSPOP_TDSQLA
For an example of granting the privileges needed to create foreign servers, see Examples of
Granting the Necessary Privileges to Use the Teradata-to-Aster Connector.
• You should become familiar with the CREATE FOREIGN SERVER and CREATE
REPLACE AUTHORIZATION syntax before you try to create a foreign server.
For information about this syntax, see CREATE FOREIGN SERVER and CREATE
AUTHORIZATION and REPLACE AUTHORIZATION.
• You can create an authorization object that stores the encrypted credentials for a user as a
database object. If you use an authorization object, then the trusted user credentials do
not need to be used when a DBA or a user creates a foreign server.
You can use the DEFINER keyword to make the authorization global for all users who
need to query the foreign server.
For information about creating an authorization object, see Creating an Authorization
Object for the Server and CREATE AUTHORIZATION and REPLACE
AUTHORIZATION.
• Create one or more foreign server objects on the Teradata Database system.
• The creators of the foreign server objects need to grant SELECT and INSERT privileges on
the foreign server objects to each Teradata user who needs to submit queries to each
foreign server.
For an example of granting the privileges needed to run queries using foreign servers, see
Examples of Granting the Necessary Privileges to Use the Teradata-to-Aster Connector.
• A Teradata DBA with the appropriate privileges needs to grant the EXECUTE
PROCEDURE privilege on ExecuteForeignSQL to users who need to run
ExecuteForeignSQL.
For an example of granting the privileges, see Examples of Granting the Necessary
Privileges to Use the Teradata-to-Aster Connector.
• A Teradata DBA with the appropriate privileges needs to grant the EXECUTE
FUNCTION privilege and SELECT privilege on ASTEREXECUTE to users who need to
run ASTEREXECUTE.
8
Teradata Database-to-Teradata Aster
Chapter 2 Getting Started with Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Setup Tasks Needed to Use the Teradata-to-Aster Connector
For an example of granting the privileges, see Examples of Granting the Necessary
Privileges to Use the Teradata-to-Aster Connector.
For additional information about granting privileges, see SQL Data Control Language,
B035-1149, and Security Administration, B035-1100.
It is considered a best practice to limit the grant of all privileges only to those DBAs and
users who need the privileges to perform their designated tasks.
Tasks To Be Performed On the Teradata Aster System
A Teradata Aster DBA with the appropriate privileges must perform the following tasks:
• Create a trusted user who acts as a proxy on the Teradata Aster system. The trusted user
must be a permanent user who has already been defined in the Teradata Aster database.
• For each Teradata end user who needs to query the foreign Aster servers, the DBA needs
to use CREATE USER to define an identical user on the Teradata Aster system.
• Set up trusted sessions for every Teradata user who queries foreign server objects, by
using GRANT teradata_username TO aster_trusted_username.
• Grant EXECUTE FUNCTION privilege to each Teradata end user (or to public) on the
following functions:
• LOAD_TO_REMOTE_TD
• LOAD_FROM_REMOTE_TD
For information about performing tasks on a Teradata Aster system, see your Teradata Aster
documentation.
Examples of Granting the Necessary Privileges to Use the Teradata-toAster Connector
Granting the Privileges Needed to Create Foreign Servers
The following example shows how to grant a DBA or user named anne_m the privilege to
create foreign servers and to associate an import operator and an export operator with them.
GRANT CREATE SERVER, DROP SERVER
ON TD_SERVER_DB
TO anne_m ;
GRANT EXECUTE FUNCTION, SELECT
ON SYSLIB.LOAD_FROM_ASTER
TO anne_m ;
GRANT EXECUTE FUNCTION, SELECT
ON SYSLIB.LOAD_TO_ASTER
TO anne_m;
Granting the Privileges Needed to Associate SYSLIB.EFSSPOP_TDSQLA
With a Foreign Server
The following example shows how to grant a DBA the privileges needed to create a foreign
server on which DBAs or users can run ExecuteForeignSQL. The foreign server creator must
have privileges on SYSLIB.EfsspOp and must associate this operator with a foreign server to
make it possible to run ExecuteForeignSQL on a foreign server. ExecuteForeignSQL allows
Teradata Database-to-Teradata Aster
9
Chapter 2 Getting Started with Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Setup Tasks Needed to Use the Teradata-to-Aster Connector
you to run basic SQL queries, such as CREATE, DROP, DELETE, and GRANT on the remote
Teradata Aster server.
GRANT EXECUTE FUNCTION, SELECT
ON SYSLIB.EFSSPOP_TDSQLA
TO anne_m;
Granting the Privileges Needed to Query Foreign Servers
The following example shows how the creator of a foreign server would grant a user named
kris_w the privileges needed to submit queries to a foreign server named aster_server_02.
GRANT SELECT, INSERT
ON aster_server_02
TO kris_w;
Granting the Privileges Needed to Run ASTEREXECUTE
The following example shows how you would grant a user named kris_w the privileges
needed to use ASTEREXECUTE syntax to export data to a Teradata Aster server and execute
a remote function on it.
GRANT EXECUTE FUNCTION, SELECT
ON SYSLIB.ASTEREXECUTE
TO kris_w;
Granting the Privileges Needed to Run ExecuteForeignSQL
The following example shows how you would grant a user named kris_w the privileges
needed to use the ExecuteForeignSQL syntax to run basic SQL queries, such as CREATE,
DROP, DELETE, and GRANT on the remote Teradata Aster server.
GRANT EXECUTE PROCEDURE
ON SYSLIB.ExecuteForeignSQL
TO kris_w;
Privileges Usage Notes
• You can specify the CREATE SERVER privilege only on the database TD_SERVER_DB.
• You can specify the DROP SERVER privilege only on the database TD_SERVER_DB.
• Only SELECT, INSERT, and SHOW privileges are allowed on foreign server objects. You
must grant SELECT, INSERT, and SHOW privileges on foreign server objects to users
who need to query foreign server objects.
• The creator of a foreign server object automatically receives DROP SERVER, SELECT,
and SHOW privileges WITH GRANT OPTION on the foreign server object.
• The creator of a foreign server object automatically receives INSERT privilege WITH
GRANT OPTION on the foreign server object if an EXPORT operator is associated with
the foreign server object.
• You cannot grant INSERT privilege on a foreign server object if the foreign server object
does not have an export operator associated with it.
• When you GRANT ALL privileges on the TD_SERVER_DB database, CREATE SERVER
and DROP SERVER privileges are included in the privileges granted.
10
Teradata Database-to-Teradata Aster
Chapter 2 Getting Started with Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata System Security
GRANT ALL ON and REVOKE ALL ON a foreign server object have different meanings,
depending on the table operators that are associated with the specified foreign server:
• Granting or revoking the ALL privilege also grants or revokes SHOW, DROP, and
SELECT privilege on a foreign server.
• The ALL privilege on the TD_SERVER_DB database includes the INSERT privilege for
foreign servers that reference export operators.
For information about the syntax of GRANT (SQL Form) and REVOKE (SQL Form), see
SQL Data Control Language, B035-1149.
Creating an Authorization Object for the Server
Optionally, you can create an authorization object for the server that stores the encrypted
credentials. You must be a database administrator to create an authorization object.
This object stores the proxy credentials for the remote logon and is typically defined as a
single global value. To make it global for all users who are granted INSERT or SELECT
privileges on the server object, you should create the object in the TD_SERVER_DB
database and use the DEFINER attribute when you create it.
For additional information about creating authorization objects, see Security Administration,
B035-1100.
1 For example, you could type the following SQL:
CREATE AUTHORIZATION td_server_db.server_name_proxy AS DEFINER
TRUSTED USER 'proxyuser' PASSWORD 'myproxy_pswrd';
The proxy is then authorized and stored in the TD_SERVER_DB database.
Teradata System Security
The Teradata-to-Aster connector does not support encryption over the wire.
The port that you use when you create a foreign server (the listening port) is protected by a
unique security key that is generated for each query by the local contract and passed as a
USING clause to the remote system. The remote system uses this key as part of its
connection information to protect against unauthorized attempts to listen on the listening
port.
One method to control system security is to limit CREATE FOREIGN SERVER privileges to
the DBA. The DBA can then grant SELECT and INSERT privileges for the foreign server
object to users to access the remote database. The user's SQL statement runs as the user
name of the session and that user name is used for security in the remote database. You can
maintain system security if you use one-to-one mapping for users on both systems.
Note that if you grant a user access to TD_SERVER_DB, the database that stores server
objects, you have also granted that user the ability to create server objects.
Teradata Database-to-Teradata Aster
11
Chapter 2 Getting Started with Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata System Security
12
Teradata Database-to-Teradata Aster
CHAPTER 3
Syntax for Teradata QueryGrid: Teradata
Database-to-Teradata Aster Database
Introduction
This chapter describes the SQL syntax and options for using the Teradata QueryGrid
connector. It includes examples that demonstrate the proper statement usage and connectorspecific grammar.
ALTER FOREIGN SERVER
Purpose
Modifies the parameters of an existing server object.
Syntax
Teradata Database-to-Teradata Aster
13
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
ALTER FOREIGN SERVER
Syntax Elements
server_name
The name given to the foreign server object.
EXTERNAL SECURITY
Associates an authorization object with the foreign server. The authorization stores the
encrypted credentials for a user as a database object. The Teradata QueryGrid connector
passes the credentials in the authorization to the remote platform identified by the
foreign server when the foreign server is accessed.
INVOKER
DEFINER
You can specify either a DEFINER or an INVOKER, but not both. If neither INVOKER
nor DEFINER are specified then INVOKER is used by default.
INVOKER is a keyword that indicates that the associated authorization must be present
in the user database at the time that the foreign server is accessed.
Note: The user database is the database that was created for the user in the Teradata
system when the user account was created.
DEFINER is a keyword that indicates that the associated authorization must be present
in the database that contains the foreign server when the foreign server is accessed.
Note: The DEFAULT keyword that can be used with DEFINER in CREATE
AUTHORIZATION and REPLACE AUTHORIZATION statements is not needed in
association with a foreign server.
If you use the DEFINER keyword, the authorization is global for all users who need to
query the foreign server.
14
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
ALTER FOREIGN SERVER
TRUSTED
A keyword that indicates the associated authorization object was created as TRUSTED.
authorization_name
Specifies the name of the authorization object to be used when the foreign server is
accessed.
Modify options
ADD
You can use to the ADD option to make the following changes:
• add or replace a global name value pair that is used to define the server object
• add an IMPORT or EXPORT table operator. If you want to replace a table operator that is
already associated with the foreign server you must first drop the table operator before
adding the new one.
name('value')
The name value pair or pairs that you want to add or modify.
IMPORT
Indicates that you are going to act on the operator that is used to import data into
Teradata Database.
EXPORT
Indicates that you are going to act on the operator that is used to export data out of
Teradata Database.
Drop options
DROP
You can use the DROP option to make the following changes:
• drop a global name value pair that was used to define a server object. You need only
specify the name to drop the pair.
• drop an IMPORT or EXPORT table operator that was associated with a server definition.
When you drop a table operator, all related name value pairs are also dropped.
name
When used alone, name is the name of the name value pair that you want to drop.
IMPORT
Indicates that you are going to act on the operator that is used to import data into
Teradata Database.
EXPORT
Indicates that you are going to act on the operator that is used to export data out of
Teradata Database
Required Name Value Pairs
These name value pairs are required to create a functioning foreign server object. You can
create a foreign server without a USING clause, but it will be nonfunctional.
Note that for sending queries and obtaining results, you also need to associate an import
operator and an export operator with a foreign server.
Teradata Database-to-Teradata Aster
15
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
ALTER FOREIGN SERVER
hosttype
The type of host to connect to. For the Teradata-to-Aster connector, this value must be
aster.
local_ips or ip_device
The IP addresses of the local Teradata nodes. You can use the IP address or the DNS
name. ip_device supports a common node device name, but the device name found by
using ifconfig must be on the same network for all nodes of the system.
remotehost
The DNS host name or IP address of the remote Teradata Aster queen node.
Note: The default port for the Teradata-to-Aster connector is 5001. If you run any other
application that listens on port 5001, you must also specify a different port number in the
CREATE or ALTER FOREIGN SERVER statement. For more information see the port NVP
in Optional Name Value Pairs.
Optional Name Value Pairs
bytecountreportfreq
The frequency with which progress is updated in Viewpoint. The default is 50MB, which
corresponds to each block. You can adjust this to a larger value if the update frequency
of once per block is too resource-intensive.
Users can override this value at the query level by using a session QUERY_BAND name
value pair. For example:
SET QUERY_BAND = 'bytecountreportfreq=256;' FOR SESSION;
concurrentstreams
The parallel efficiency to use. This value determines the number of parallel socket
connections that are established between a local Teradata node and a remote Teradata
Aster vworker.
The valid range is 1 to 5. The default value is 1. With a value of 1, a node on the foreign
server reads the requested data and uses the established socket connection to send the
data in 64KB blocks to a node on the local system
If your network bandwidth setup can support higher values, users may want to override
this server value at the query level by using a session QUERY_BAND name value pair.
For example:
SET QUERY_BAND = 'concurrentstreams=2;' FOR SESSION;
dbname
The database to connect to. You can use the dbname name value pair in the server object
to limit access to specific databases. The default is beehive. This parameter is required if
you use schemaname. The database name in the server object overrides users' selections.
disable_pushdown
When set to true, disables the pushdown of all query conditions to the remote system.
Valid values are true and false. By default, this NVP is set to false.
Certain system level, session level, and column level query attributes (such as casespecific) can affect character string comparison results. These attributes can cause some
queries to return incorrect results due to incorrect row filtering on the remote system.
To avoid incorrect results caused by condition pushdown in situations where the
16
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
ALTER FOREIGN SERVER
settings on the local system do not match the settings on the remote system, you can
disable the pushdown of all conditions to the remote system.
For example, consider the following query and its EXPLAIN:
explain SELECT * from UPTT48.table1@MyforeignServer where x2 <
'012';
The following EXPLAIN illustrates the processing of the query when
disable_pushdown is set to true, and therefore no condition pushdown takes place
during processing.
Explanation
----------------------------------------------------------------------1) First, we do an all-AMPs RETRIEVE step executing table operator
syslib.load_from_td with a condition of ("table1.X2 < '012 '").
< BEGIN EXPLAIN FOR REMOTE QUERY -->
We get external query:'SELECT x1 ,x2 FROM UPTT48.table1 WHERE X2 <
'012 '' for target system:server1.mycompany.com. 1) First, we
lock a distinct UPTT48."pseudo table" for read on a RowHash to
prevent global deadlock for UPTT48.table1. 2) Next, we lock
UPTT48.table1 for read. 3) We do an all-AMPs RETRIEVE step from
UPTT48.table1 by way of an all-rows scan with a condition of
("UPTT48.table1.x2 < '012 '") executing table operator
SYSLIB.load_to_tdRemote with a condition of ("(1=1)") into Spool 2
(used to materialize view, derived table, table function or table
operator d) (all_amps), which is built locally on the AMPs.
The size of Spool 2 is estimated with no confidence to be 3 rows
(64,068 bytes). The estimated time for this step is 0.16 seconds.
4) We do an all-AMPs RETRIEVE step from Spool 2 (Last Use) by way
of an all-rows scan into Spool 3 (group_amps), which is built
locally on the AMPs. The size of Spool 3 is estimated with no
confidence to be 3 rows (64,068 bytes). The estimated time for
this step is 0.16 seconds. 5) Finally, we send out an END
TRANSACTION step to all AMPs involved in processing the request.
-> The contents of Spool 3 are sent back to the user as the result
of statement 1. The total estimated time is 0.32 seconds.
<-- END EXPLAIN FOR REMOTE QUERY >
The size of Spool 1 is estimated with low confidence to be 80,000
rows (2,800,000 bytes). The estimated time for this step is 0.13
seconds.
2) Next, we do an all-AMPs RETRIEVE step from Spool 1 (Last Use) by
way of an all-rows scan with a condition of ("table1.X2 < '012 '")
into Spool 2 (group_amps), which is built locally on the AMPs.
The size of Spool 2 is estimated with no confidence to be 80,000
rows (3,360,000 bytes). The estimated time for this step is 0.54
seconds.
3) Finally, we send out an END TRANSACTION step to all AMPs involved
in processing the request.
-> The contents of Spool 2 are sent back to the user as the result of
statement 1. The total estimated time is 0.67 seconds.
The following EXPLAIN illustrates the processing of the query when disable_pushdown
is set to false, and processing is pushed down onto the remote system.
Teradata Database-to-Teradata Aster
17
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
ALTER FOREIGN SERVER
Explanation
----------------------------------------------------------------------1) First, we do an all-AMPs RETRIEVE step executing table operator
syslib.load_from_td with a condition of ("table1.X2 < '012 '").
< BEGIN EXPLAIN FOR REMOTE QUERY -->
We get external query:'SELECT x1 ,x2 FROM UPTT48.table1 ' for
target system:server1.mycompany.com. 1) First, we lock a distinct
UPTT48."pseudo table" for read on a RowHash to prevent global
deadlock for UPTT48.table1. 2) Next, we lock UPTT48.table1 for
3) We do an all-AMPs RETRIEVE step from UPTT48.table1 by way of an
read. all-rows scan with no residual conditions executing table
operator SYSLIB.load_to_tdRemote with a condition of ("(1=1)")
into Spool 2 (used to materialize view, derived table, table
function or table operator d) (all_amps), which is built locally
on the AMPs. The size of Spool 2 is estimated with low confidence
to be 8 rows (170,848 bytes). The estimated time for this step
is 0.16 seconds.
4) We do an all-AMPs RETRIEVE step from Spool 2 (Last Use) by way
of an all-rows scan into Spool 3 (group_amps), which is built
locally on the AMPs. The size of Spool 3 is estimated with low
confidence to be 8 rows (170,848 bytes). The estimated time for
this step is 0.16 seconds. 5) Finally, we send out an END
TRANSACTION step to all AMPs involved in processing the request.
-> The contents of Spool 3 are sent back to the user as the result
of statement 1. The total estimated time is 0.32 seconds.
<-- END EXPLAIN FOR REMOTE QUERY >
The size of Spool 1 is estimated with low confidence to be 80,000
rows (2,800,000 bytes). The estimated time for this step is 0.13
seconds.
2) Next, we do an all-AMPs RETRIEVE step from Spool 1 (Last Use) by
way of an all-rows scan with a condition of ("table1.X2 < '012 '")
into Spool 2 (group_amps), which is built locally on the AMPs.
The size of Spool 2 is estimated with no confidence to be 80,000
rows (3,360,000 bytes). The estimated time for this step is 0.54
seconds.
3) Finally, we send out an END TRANSACTION step to all AMPs involved
in processing the request.
-> The contents of Spool 2 are sent back to the user as the result of
statement 1. The total estimated time is 0.67 seconds.
listen_timeout
The number of seconds to wait for one connection while listening. The default is 60
seconds. This value represents the time period in which the query is parsed, runs on the
foreign server, and returns results to the local system. If you are accessing large tables on
the foreign server, you may want to increase this value to avoid having queries time out.
Users can override this server value at the query level by using a session QUERY_BAND
name value pair. For example:
SET QUERY_BAND = 'listen_timeout=180;' FOR SESSION;
port
The local port number to which the foreign server can connect. This port must remain
open. The default is 5001. If you run any other application that listens on port 5001, you
18
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
ALTER FOREIGN SERVER
must specify a different port number in the CREATE or ALTER FOREIGN SERVER
statement.
Note: This NVP is an exception to the rule that you do not use surrounding apostrophes
(single quotation marks) for name value pairs that are composed entirely of integers.
You must delimit the port value with apostrophes.
For example, following is the correct syntax for a port number:
port ('6001')
read_timeout
The number of seconds to wait on the socket. The default value is 30.
Users can override this server value at the query level by using a session QUERY_BAND
name value pair. For example:
SET QUERY_BAND = 'read_timeout=60;' FOR SESSION;
schemaname
The name of the schema to use when you import or export queries.
The Teradata-to-Aster connector supports and passes the following server name value pairs
to the Teradata Aster system:
• local_ips
• read_timeout
• port
If a user uses SET QUERY_BAND to set any of these values for a session, then the
QUERY_BAND values take precedence over the values that were set when a foreign server
object was created or last altered.
Required Privileges
You must have DROP SERVER privilege on the TD_SERVER_DB database or on the
specified foreign server to modify the foreign server object. If you are modifying the table
operators that are associated with the server, or adding a table operator, you must also have
EXECUTE FUNCTION and SELECT privileges on the specified table operators.
Usage Notes
You cannot use the following names in the name value pairs in ALTER SERVER statements:
• Columns
• hExplain
• IsNested
• Servermode
Note: External security options and ADD or DROP clauses must be specified in the syntax.
Teradata Database-to-Teradata Aster
19
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
AsterExecute
Example of Using ALTER FOREIGN SERVER Syntax
This example demonstrates altering a foreign server in Teradata Database by changing the
number of parallel socket connections between the Teradata Database node and the Teradata
Aster vworker.
ALTER FOREIGN SERVER remote_system
ADD concurrentstreams(2) ;
AsterExecute
Purpose
The AsterExecute table operator exports data from a Teradata Database system to a Teradata
Aster server (the foreign server), executes a remote function, and returns the results.
20
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
AsterExecute
Syntax
Syntax Elements
select_options
You can use any valid Teradata Database select options for the SELECT clause, such as an
asterisk (*) for all data or standard column selection criteria, such as a partial column list.
Teradata Database-to-Teradata Aster
21
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
AsterExecute
ON
Introduces the object or expression that you want to act on. You can specify up to 16 ON
clauses, but the number of ON clauses in this SELECT must match the number of %s
placeholders for temporary table names that you have in the ON clauses in the remote query.
table_name
The name of a table on the Teradata server to use in the query.
table_name@foreign_server_name
The name of a table on a foreign server to use in the query. The table can be on a
Teradata Aster server, or, if you are also using the appropriate Teradata QueryGrid
connector, the table can be on an Oracle server or on a remote Teradata server. If the
table is on a Teradata Aster server, you can optionally qualify it with the schema name.
The foreign server where the table is located does not have to be the same foreign server
as the foreign server on which the Aster analytical function is run
(aster_foreign_svr_name, which appears just before the USING clause).
query_expression
A query expression that is input to the table operator. You can use any valid Teradata
Database query that generates a data set.
correlation_name
An alias for the table that is referenced in the ON clause.
HASH BY
An optional set of column names on which to hash order globally the columns input to a
table function or table operator.
When you use a multiple input table operator that has multiple hash by clauses, the following
restrictions apply:
• All of them must have the same number of partitioning parameters.
• The corresponding parameters must be the same type or matched using an implicit cast.
If you specify a LOCAL ORDER BY clause along with a HASH BY clause, the following
restrictions apply:
• All the clauses must have the same number of LOCAL ORDER BY columns.
• The data types of the columns must be the same type or matched using an implicit cast.
For more information about HASH BY, see SQL Data Manipulation Language.
PARTITION BY
PARTITION BY
To partition for a table specified as input to a table operator.
You cannot specify a row-level security constraint column as a partitioning column. You
can specify a column by name or position, or use an expression that resolves to a
column.
If you have multiple PARTITION BY clauses, the following restrictions apply:
• All of them must have the same number of partitioning parameters.
• The corresponding parameters must be the same type or matched using an implicit
cast.
22
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
AsterExecute
If you specify an ORDER BY clause with a PARTITION BY clause, the following
restrictions apply:
• All the clauses must have the same number of ORDER BY columns.
• The data types of the columns must be the same type or matched using an implicit
cast.
PARTITION BY ANY
Specifies a table with no partitioning or order by parameters.
PARTITION BY ANY preserves the existing distribution of the rows on the AMPs. A
PARTITION BY ANY clause followed by ORDER BY clause means that all the rows are
ordered by the ORDER BY clause on that partition, and it is functionally equivalent to
using LOCAL ORDER BY without using a HASH BY clause.
The following restrictions apply:
• You cannot specify a PARTITION BY ANY clause and a LOCAL ORDER BY clause
in the same ON clause.
• If you specify multiple ON clauses with a table operator, you can only specify one
PARTITION BY ANY clause. All other clauses must be DIMENSION
For more information about PARTITION BY and PARTITION BY ANY, see SQL Data
Manipulation Language.
DIMENSION
Specifies that a duplicate copy of the dimension table is created for every partition on which
the table operator operates. You can specify zero or more DIMENSION clauses for each ON
clause.
The following restrictions apply:
• You cannot use a LOCAL ORDER BY clause and a DIMENSION clause in the same ON
clause.
• If you have only one ON clause as input to a table operator, you cannot use DIMENSION
in it. You must have at least one PARTITION BY or HASH BY clause in a second ON
clause to use DIMENSION.
• If you use multiple ON clauses and you specify only LOCAL ORDER BY in one of them,
then all other ON clauses can only specify DIMENSION.
For more information about DIMENSION, see SQL Data Manipulation Language.
ORDER BY
LOCAL ORDER BY
Specifies that qualified rows are ordered on each AMP in preparation to be input to a
table function.
You cannot use a LOCAL ORDER BY clause in addition to a DIMENSION clause in
the same ON clause.
If you use multiple ON clauses, you cannot specify a LOCAL ORDER BY clause in
addition to a PARTITION BY ANY clause in the same ON clause.
If you use multiple ON clauses and you specify only LOCAL ORDER BY in one of
them, then all other ON clauses can only specify a DIMENSION clause.
If you specify multiple HASH BY clauses with LOCAL ORDER BY clauses, the
following restrictions apply:
• All of the clauses must have the same number of LOCAL ORDER BY columns.
Teradata Database-to-Teradata Aster
23
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
AsterExecute
• The data types of the columns must be the same type or matched using an implicit
cast.
ORDER BY
How result sets are sorted. If you do not use this clause, result rows are returned
unsorted.
You cannot specify ORDER BY as the only option in an ON clause. You must combine
it with a PARTITION BY, PARTITION BY ANY, HASH BY, or DIMENSION clause.
If you specify an ORDER BY clause with a PARTITION BY clause, the following
restrictions apply:
• All of the clauses must have the same number of ORDER BY columns.
• The data types of the columns must be the same type or matched using an implicit
cast.
• When NORMALIZE and ORDER BY are specified in a query, the rows are
normalized first and the result is ordered on the normalized result.
For more information about LOCAL ORDER BY and ORDER BY, see SQL Data
Manipulation Language.
aster_foreign_svr_name
The name of the Teradata Aster foreign server where the query is to run.
select_options
Any valid select options, such as an asterisk (*) to select all data, or a partial column list from
the list of columns returned for the specified Aster analytical function.
aster_analytical_function
The Teradata Aster analytical function to execute on the Teradata Aster server.
To see a list of the Aster analytical functions that the Teradata-to-Aster connector supports,
see Supported Aster Functions.
For more information about the Teradata Aster analytical functions, see the Teradata Aster
documentation available at www.info.teradata.com.
ON
Introduces one or more tables that contain the data to be analyzed by the specified Aster
analytical function. The number of ON clauses allowed here depends on the Aster analytical
function that you use.
%s
A string that is automatically replaced with a Teradata Aster table identifier used for the
data that is sent in the first set of ON clauses. Each %s corresponds positionally to one
ON statement in the outer SELECT. You must have one ON %s clause in the remote
query for every ON clause in the outer SELECT.
aster_table_name
The name of a table on the foreign server for the Teradata Aster analytical function to
act on.
aster_partition_and_order_options
Any valid Teradata Aster options for an ON clause, such as PARTITION BY ANY,
ORDER BY, and DIMENSION.
24
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
AsterExecute
For information about Teradata Aster partition and order options, see the Teradata
Aster Database User Guide located at www.info.teradata.com.
aster_analytical_function_options
Any valid options for the specified Teradata Aster analytical function.
For information about Teradata Aster analytical function options, see the Teradata Aster
Analytics Foundation User Guide located at www.info.teradata.com.
SUBSTITUTE
Introduces one or more strings to replace and the replacement strings for the remote query
that you are running on the Teradata Aster server. You can make any number of
substitutions, and spaces in this expression are ignored.
The SUBSTITUTE clause is useful, for example, to avoid having to escape apostrophes
(single quotation marks) in the remote query. For an example that uses apostrophes and
double quotation marks in a SUBSTITUTE clause, see Usage Notes.
string1
The string that you want to be replaced in the remote query.
->
The dash (-) and greater than (>) literal symbols.
string2
The string that you want to be used in the remote query that executes on the Teradata
Aster server.
AS
Introduces the alias name for the derived table or the alias name with a comma-separated,
filtered column list.
correlation_name
The name that you want to use for the table that is created by the execution of the
remote query. This derived table name can be used in the query later, and it can contain
a filtered column list, as in correlation_name(col1, col2).
column_name
A column, or list of columns separated by commas, to use from the derived table, for
example, tv_spots(col1, col2).
Required Privileges
You must have EXECUTE FUNCTION and SELECT privileges on AsterExecute to use this
function.
Usage Notes
• The AsterExecute table operator is located in the SYSLIB database.
• You do not need to know the names of the columns that will be returned if all columns
are being retrieved from the function execution.
• Teradata Aster expects an apostrophe (single quotation mark) around certain types of
expressions where Teradata Database expects a double quotation mark ("). For example,
if you use the Teradata Aster PATTERN analytical function in your query, you need to
Teradata Database-to-Teradata Aster
25
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
AsterExecute
either escape each apostrophe with a second apostrophe, or you can use the
SUBSTITUTE clause to ensure that the double quotation marks needed to satisfy
Teradata syntax requirements are translated to apostrophes when the remote query runs
on the Teradata Aster server.
For example, in the following query, each apostrophe is escaped by a second apostrophe to
satisfy Teradata Database syntax, as follows:
SELECT * FROM ASTEREXECUTE
(
ON (SELECT * FROM tab1) @astersrv1 USING
REMOTEQUERY('select * from sessionize (on %s partition by(''c1'')
order by (''c1'') timecolumn (''c1'') timeout (''3000'') )')
) AS tv_spots;
If you use the SUBSTITUTE clause instead, you can use the double quotation marks and
your query would look as follows:
SELECT * FROM ASTEREXECUTE
(
ON (SELECT * FROM tab1) @astersrv1 USING
REMOTEQUERY('select * from sessionize (on %s partition by("c1")
order by ("c1") timecolumn ("c1") timeout ("3000") )')
SUBSTITUTE(' " -> '' ')
) AS tv_spots;
For examples of using AsterExecute, see Using the Teradata-to-Aster Connector with
SELECT Statements.
Supported Aster Functions
The following table shows the supported Aster Time Series, Path and Attribution Analysis
functions:
Aster Function
Notes
Attribution
CMAVG
Cumulative Moving AVG
DTW
Dynamic Time Warping
Path_Generator
Path_Start
Path_Summarizer
SAX
Symbolic aggregate approximation
Sessionize
The following table shows the supported Aster Pattern Matching functions:
Aster Function
Notes
nPath
The following table shows the supported Aster Statistical Analysis functions:
26
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
AsterExecute
Aster Function
Notes
ApproxDCountReduce/ApproxDCountMap
Approximate Distinct Count
ApproxPercentileReduce/ApproxPercentileMap
ConfusionMatrix
ConfusionMatrixPlot
Corr_Reduce
Correlation
distnmatch
Distribution Matching
EMAVG
Exponential Moving Average
Hist_map
Histogram
Hist_reduce
FMeasure
Histogram_map
LARSPredict
Least Angle Regression
LinReg
Linear regression
Pca_Reduce
Pca_Map
Principal Component Analysis
Percentile
SMAVG
Simple Moving Average
Sample
SparseSVMPredictor
Support Vector Machines
SVMModelPrinter
Support Vector Machines
VWAP
Volume-Weighted Average Price
WMAVG
Weighted Moving Average
The following table shows the supported Aster Text Analysis functions:
Aster Function
Notes
EvaluateNamedEntityFinderRow /
EvaluateNamedEntityFinderPartition
Named Entity Recognition (NER)
EvaluateSentimentExtractor
Sentiment Extraction Functions
ExtractSentiment
Sentiment Extraction Functions
FindNamedEntity
Named Entity Recognition (NER)
LDATopicPrinter
ldist
Levenshtein distance
NaiveBayesText
Teradata Database-to-Teradata Aster
27
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
AsterExecute
Aster Function
Notes
NaiveBayesTextPredict
nGram
PosTagger
Parts-Of-Speech Tagger
Sentenizer
TF_IDF
Term Frequency-Inverse Document Frequency
TextChunker
TextClassifier
TextClassifierEvaluator
Text_Parser
TextMorph
TextTagging
TextTokenizer
The following table shows the supported Aster Cluster Analysis functions:
Aster Function
Notes
KmeansPlot
The following table shows the supported Aster Naive Bayes functions:
Aster Function
Notes
naiveBayesMap
naiveBayesReduce
The following table shows the supported Aster Decision Trees functions:
Aster Function
Notes
Forest_Analyze
Random Forest Function
single_tree_predict
Single Decision Tree Function
The following table shows the supported Aster Association Analysis functions:
Aster Function
Notes
Basket_Generator
WSRecommender
Weighted-sum recommendations
The following table shows the supported Aster Graph Analysis functions:
Aster Function
Notes
AllPairsShortestPath
28
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
AsterExecute
Aster Function
Notes
Betweenness
Closeness
EigenvectorCentrality
LocalClusteringCoefficient
LoopyBeliefPropagation
nTree
PageRank
The following table shows the supported Aster Data Transformation functions:
Aster Function
Notes
Antiselect
apache_log_parser
IdentityMatch
IpGeo
JSONParser
Multi_case
MurmurHash
PSTParserAFS
Personal Storage Table
Pack
Pivot
Unpack
Unpivot
XMLParser
XMLRelation
The following table shows the supported Aster Data Visualization functions:
Aster Function
Notes
CfilterViz
NpathViz
Teradata Database-to-Teradata Aster
29
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
BEGIN LOGGING
BEGIN LOGGING
Purpose
Starts the auditing of SQL requests that attempt to access data.
This topic describes only the portions of the BEGIN LOGGING syntax diagram that are
specific to this Teradata QueryGrid connector. For information about the other syntax that
you can use with BEGIN LOGGING, see SQL Data Definition Language - Syntax and
Examples, B035-1144.
Syntax
BEGIN LOGGING
ON
A
WITH TEXT
DENIALS
FIRST
LAST
FIRST AND LAST
EACH
A
FOR CONSTRAINT
constraint_name
ALL
,
operation
GRANT
B
,
BY
database_name
user_name
B
,
ON
;
20
AUTHORIZATION authorization_name
DATABASE database_name
USER database_name
TABLE
object_name
VIEW
database_name.
MACRO
user_name.
PROCEDURE
FUNCTION
TYPE
FOREIGN SERVER
Syntax Element
ON FOREIGN SERVER object_name
Indicates that the database object for which access is to be logged is a foreign server.
You must specify an object name, which is the name of the foreign server. You can
optionally specify the name of the containing database, which must be
TD_SERVER_DB. You cannot use a user_name with FOREIGN SERVER.
30
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
COMMENT (Comment Placing Form)
COMMENT (Comment Placing Form)
Purpose
Creates a user-defined description of a user-defined database object or definition in the data
dictionary.
This topic describes only the portions of the COMMENT syntax diagram that are specific to
Teradata QueryGrid. For information about the other syntax elements in COMMENT
(Comment Placing Form), see SQL Data Definition Language - Syntax and Examples,
B035-1144.
Syntax
COMMENT
ON
object_kind_1
object_kind_2
object_name
database_name.
user_name.
'comment'
;
AS
IS
Syntax Element
object_kind_2
An optional database object kind specification.
You can specify the following database object kinds to retrieve a comment for the kind
of object they represent, but they are optional.
• DATABASE
• FOREIGN SERVER
• TABLE
• USER
If you specify an optional database_name with FOREIGN SERVER, the name must be
TD_SERVER_DB. You cannot use a user_name with FOREIGN SERVER.
All existing rules for COMMENT apply for use with a FOREIGN SERVER object.
The optional comment string is recorded in DBC.TVM.
For more information about using COMMENT (Comment Placing Form), see SQL Data
Definition Language - Syntax and Examples, B035-1144.
CREATE AUTHORIZATION and REPLACE
AUTHORIZATION
Purpose
Creates or replaces an authorization object in Teradata Database. The authorization stores
credentials for a user account that exists on a remote platform. The credentials need only be
Teradata Database-to-Teradata Aster
31
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE AUTHORIZATION and REPLACE AUTHORIZATION
valid on the platform specified in the foreign server object; they do not need to be valid on
the Teradata Database or on its underlying operating system. When you specify TRUSTED in
the CREATE or REPLACE AUTHORIZATION statement, Teradata Database does not
validate the credentials.
For Teradata QueryGrid, an authorization object is used by a foreign server object to log into
a remote platform using credentials that are valid on the remote platform. When a Teradata
user makes a request that uses the foreign server, the foreign server object provides the
credentials from the authorization object to the target platform for authentication. This
allows any part of the request that runs on the remote platform to use the context, privileges,
and access control granted to the remote platform user account.
For example, if the foreign server connects to a Teradata Aster Database that authenticates
users using the OS platform, then the associated authorization object must contain
credentials for the OS platform user account.
The syntax table describes only the portions of the CREATE AUTHORIZATION and
REPLACE AUTHORIZATION syntax diagram that are specific to Teradata QueryGrid. For
information about the other syntax that you can use with CREATE AUTHORIZATION and
REPLACE AUTHORIZATION, see SQL Data Definition Language - Syntax and Examples,
B035-1144.
Syntax
Syntax Elements
database_name.
user_dbname.
Optional name of the location where the authorization is to be stored.
The default location that is used changes based on whether DEFINER or INVOKER is
specified. The following rules apply to specifying DEFINER or INVOKER:
• If you specify DEFINER, the database or user you specify must be the containing
database or user for the foreign server, UDF, table UDF, method, or external SQL
procedure. If no location is specified, the authorization is created in the database that
contains the foreign server objects (TD_SERVER_DB).
• If you specify INVOKER, the database_name or user_dbname you specify must be
associated with the session user who will be sending requests to the foreign server. If
no location is specified, the authorization is placed in the user database of the creator
of the authorization.
authorization_name
Name for the authorization object. This name must be unique within the database in
which it is stored.
32
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE AUTHORIZATION and REPLACE AUTHORIZATION
INVOKER
DEFINER
• If you specify INVOKER TRUSTED, or if you specify TRUSTED alone, Teradata
creates the authorization object in the database of the user who creates the object.
This syntax makes the authorization available only to those with privilege to the user
database.
• If you specify DEFINER TRUSTED or DEFINER DEFAULT TRUSTED, then
Teradata creates the authorization object in the database that contains the object that
is using the authorization; for a foreign server this is the TD_SERVER_DB database.
This syntax makes the authorization globally available.
TRUSTED
A keyword used to specify that the credentials are to be encrypted and stored as
database objects.
You cannot use TRUSTED authorizations in CREATE or REPLACE UDF or XSP
statements.
'fs_user_name'
The name of the credential on the remote platform to be used by the foreign server.
'fs_password'
The password for the credential on the remote platform to be used by the foreign server.
All existing rules for CREATE AUTHORIZATION and REPLACE AUTHORIZATION
apply.
For more information about using CREATE AUTHORIZATION and REPLACE
AUTHORIZATION, see SQL Data Definition Language - Syntax and Examples,
B035-1144.
Usage Notes
• A proxy user can be used by one or more trusted authorization objects. To drop the
proxy, you need to drop the authorization on the proxy. For example:
DROP FOREIGN SERVER TD_SERVER_DB.remote_system ;
DROP AUTHORIZATION TD_SERVER_DB.remote_proxy ;
You do not have to drop the foreign server objects that are used by the proxy, but it is a
best practice to do so, because you must have an authorization associated with a foreign
server object in order to reference the object. If you drop an authorization but do not
drop a foreign server object that uses it, then the next time that you try to reference the
foreign server object, you get an error message.
• The proxy users who are configured to use the Teradata-to-Aster connector are users who
are defined on the remote Teradata Aster database. A DBA on the remote Teradata Aster
system can drop these individual Teradata Aster users on the Teradata Aster system
without any constraints.
However, before a DBA on the remote Teradata Aster system drops a remote proxy user, a
DBA on the Teradata system should drop the authorization and foreign server objects as
well. If the authorization and foreign server objects on the Teradata system are not
dropped first, users see errors during query execution.
• If the credentials change on the foreign server's target platform, you must remember to
replace the credentials in the authorization object. If you fail to update the invalid
Teradata Database-to-Teradata Aster
33
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE FOREIGN SERVER
information, the next time that you try to reference the foreign server object, you get an
error message.
• If you drop an authorization object, keep in mind that it may be used by multiple foreign
server objects. You should either drop the foreign server objects or alter them so that they
specify a valid authorization object. If you fail to update the invalid information, the next
time that you try to reference the foreign server object, you get an error message.
Examples of Creating and Replacing the Authorization
If you want to make the authorization available globally, create the authorization on
TD_SERVER_DB using the DEFINER TRUSTED type.
CREATE AUTHORIZATION TD_SERVER_DB.remote_system1
AS DEFINER TRUSTED USER 'proxy_1'
PASSWORD 'Global' ;
If you use DEFINER TRUSTED, as in this example, then the credentials for sales must be
created in the TD_SERVER_DB database.
CREATE AUTHORIZATION TD_SERVER_DB.sales AS DEFINER TRUSTED
USER 'johnson'
PASSWORD 'Secret';
The following two examples establish authorization for the user who invokes the object. The
credentials are encrypted and stored in the user database as an object.
CREATE AUTHORIZATION sales AS TRUSTED
USER 'johnson'
PASSWORD 'Secret' ;
REPLACE AUTHORIZATION sales AS INVOKER TRUSTED
USER 'williams'
PASSWORD 'topsecret' ;
CREATE FOREIGN SERVER
Purpose
Creates a foreign server object and associates table operators with it.
When you create a server object, you can customize it based on its purpose. You can define
multiple server objects for the same remote database, each with different characteristics
needed by different users.
You can use name value pairs to define the characteristics of the foreign server.
34
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE FOREIGN SERVER
Syntax
CREATE FOREIGN SERVER
server_name
A
TRUSTED authorization_name
EXTERNAL SECURITY
INVOKER
DEFINER
A
using option
DO IMPORT WITH
;
operator option
, DO EXPORT WITH
operator option
operator option
table_operator
using option
database_name.
Syntax Elements
server_name
The name given to the foreign server object.
EXTERNAL SECURITY
Associates an authorization object with the foreign server. The authorization stores the
encrypted credentials for a user as a database object. The Teradata QueryGrid
connector passes the credentials in the authorization to the remote platform identified
by the foreign server when the foreign server is accessed.
INVOKER
DEFINER
You can specify either a DEFINER or an INVOKER, but not both. If neither INVOKER
nor DEFINER are specified then INVOKER is used by default.
INVOKER is a keyword that indicates that the associated authorization must be present
in the user database at the time that the foreign server is accessed.
Note: The user database is the database that was created for the user in the Teradata
system when the user account was created.
DEFINER is a keyword that indicates that the associated authorization must be present
in the database that contains the foreign server when the foreign server is accessed.
Note: The DEFAULT keyword that can be used with DEFINER in CREATE
AUTHORIZATION and REPLACE AUTHORIZATION statements is not needed in
association with a foreign server.
Teradata Database-to-Teradata Aster
35
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE FOREIGN SERVER
If you use the DEFINER keyword, the authorization is global for all users who need to
query the foreign server.
TRUSTED
A keyword that indicates the associated authorization object was created as TRUSTED.
authorization_name
Specifies the name of the authorization object to be used when the foreign server is
accessed.
Using option
USING
USING introduces the global name value pairs (NVPs) that provide the server definition
information. USING must be followed by at least one name value pair of the form
name('value'), but an empty value of ' ' is supported. You can create a foreign server without a
USING clause, but users cannot query a foreign server until you complete the server
definition with an import operator and an export operator.
Note: With the exception of the port NVP, do not use surrounding apostrophes (single
quotation marks) for name value pairs that are composed entirely of integers. NVPs that
contain only integers are handled differently from those that contain alphabetic strings,
alphanumeric strings, or characters and integers, such as an IP address. If you delimit an
integer value with apostrophes, then the value is silently ignored and the default value is used
instead.
Required Name Value Pairs
These name value pairs are required to create a functioning foreign server object. You can
create a foreign server without a USING clause, but it will be nonfunctional.
Note that for sending queries and obtaining results, you also need to associate an import
operator and an export operator with a foreign server.
hosttype
The type of host to connect to. For the Teradata-to-Aster connector, this value must be
aster.
local_ips or ip_device
The IP addresses of the local Teradata nodes. You can use the IP address or the DNS
name. ip_device supports a common node device name, but the device name found by
using ifconfig must be on the same network for all nodes of the system.
remotehost
The DNS host name or IP address of the remote Teradata Aster queen node.
Note: The default port for the Teradata-to-Aster connector is 5001. If you run any other
application that listens on port 5001, you must also specify a different port number in the
CREATE or ALTER FOREIGN SERVER statement. For more information see the port NVP
in Optional Name Value Pairs.
36
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE FOREIGN SERVER
Optional Name Value Pairs
bytecountreportfreq
The frequency with which progress is updated in Viewpoint. The default is 50MB,
which corresponds to each block. You can adjust this to a larger value if the update
frequency of once per block is too resource-intensive.
Users can override this value at the query level by using a session QUERY_BAND name
value pair. For example:
SET QUERY_BAND = 'bytecountreportfreq=256;' FOR SESSION;
concurrentstreams
The parallel efficiency to use. This value determines the number of parallel socket
connections that are established between a local Teradata node and a remote Teradata
Aster vworker.
The valid range is 1 to 5. The default value is 1. With a value of 1, a node on the foreign
server reads the requested data and uses the established socket connection to send the
data in 64KB blocks to a node on the local system
If your network bandwidth setup can support higher values, users may want to override
this server value at the query level by using a session QUERY_BAND name value pair.
For example:
SET QUERY_BAND = 'concurrentstreams=2;' FOR SESSION;
dbname
The database to connect to. You can use the dbname name value pair in the server
object to limit access to specific databases. The default is beehive. This parameter is
required if you use schemaname. The database name in the server object overrides
users' selections.
disable_pushdown
When set to true, disables the pushdown of all query conditions to the remote system.
Valid values are true and false. By default, this NVP is set to false.
Certain system level, session level, and column level query attributes (such as casespecific) can affect character string comparison results. These attributes can cause some
queries to return incorrect results due to incorrect row filtering on the remote system.
To avoid incorrect results caused by condition pushdown in situations where the
settings on the local system do not match the settings on the remote system, you can
disable the pushdown of all conditions to the remote system.
For example, consider the following query and its EXPLAIN:
explain SELECT * from UPTT48.table1@MyforeignServer where x2 <
'012';
The following EXPLAIN illustrates the processing of the query when
disable_pushdown is set to true, and therefore no condition pushdown takes place
during processing.
Explanation
----------------------------------------------------------------------1) First, we do an all-AMPs RETRIEVE step executing table operator
syslib.load_from_td with a condition of ("table1.X2 < '012 '").
< BEGIN EXPLAIN FOR REMOTE QUERY -->
We get external query:'SELECT x1 ,x2 FROM UPTT48.table1 WHERE X2 <
'012 '' for target system:server1.mycompany.com. 1) First, we
Teradata Database-to-Teradata Aster
37
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE FOREIGN SERVER
lock a distinct UPTT48."pseudo table" for read on a RowHash to
prevent global deadlock for UPTT48.table1. 2) Next, we lock
UPTT48.table1 for read. 3) We do an all-AMPs RETRIEVE step from
UPTT48.table1 by way of an all-rows scan with a condition of
("UPTT48.table1.x2 < '012 '") executing table operator
SYSLIB.load_to_tdRemote with a condition of ("(1=1)") into Spool 2
(used to materialize view, derived table, table function or table
operator d) (all_amps), which is built locally on the AMPs.
The size of Spool 2 is estimated with no confidence to be 3 rows
(64,068 bytes). The estimated time for this step is 0.16 seconds.
4) We do an all-AMPs RETRIEVE step from Spool 2 (Last Use) by way
of an all-rows scan into Spool 3 (group_amps), which is built
locally on the AMPs. The size of Spool 3 is estimated with no
confidence to be 3 rows (64,068 bytes). The estimated time for
this step is 0.16 seconds. 5) Finally, we send out an END
TRANSACTION step to all AMPs involved in processing the request.
-> The contents of Spool 3 are sent back to the user as the result
of statement 1. The total estimated time is 0.32 seconds.
<-- END EXPLAIN FOR REMOTE QUERY >
The size of Spool 1 is estimated with low confidence to be 80,000
rows (2,800,000 bytes). The estimated time for this step is 0.13
seconds.
2) Next, we do an all-AMPs RETRIEVE step from Spool 1 (Last Use) by
way of an all-rows scan with a condition of ("table1.X2 < '012 '")
into Spool 2 (group_amps), which is built locally on the AMPs.
The size of Spool 2 is estimated with no confidence to be 80,000
rows (3,360,000 bytes). The estimated time for this step is 0.54
seconds.
3) Finally, we send out an END TRANSACTION step to all AMPs involved
in processing the request.
-> The contents of Spool 2 are sent back to the user as the result of
statement 1. The total estimated time is 0.67 seconds.
The following EXPLAIN illustrates the processing of the query when
disable_pushdown is set to false, and processing is pushed down onto the remote
system.
Explanation
----------------------------------------------------------------------1) First, we do an all-AMPs RETRIEVE step executing table operator
syslib.load_from_td with a condition of ("table1.X2 < '012 '").
< BEGIN EXPLAIN FOR REMOTE QUERY -->
We get external query:'SELECT x1 ,x2 FROM UPTT48.table1 ' for
target system:server1.mycompany.com. 1) First, we lock a distinct
UPTT48."pseudo table" for read on a RowHash to prevent global
deadlock for UPTT48.table1. 2) Next, we lock UPTT48.table1 for
3) We do an all-AMPs RETRIEVE step from UPTT48.table1 by way of an
read. all-rows scan with no residual conditions executing table
operator SYSLIB.load_to_tdRemote with a condition of ("(1=1)")
into Spool 2 (used to materialize view, derived table, table
function or table operator d) (all_amps), which is built locally
on the AMPs. The size of Spool 2 is estimated with low confidence
to be 8 rows (170,848 bytes). The estimated time for this step
38
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE FOREIGN SERVER
is 0.16 seconds.
4) We do an all-AMPs RETRIEVE step from Spool 2 (Last Use) by way
of an all-rows scan into Spool 3 (group_amps), which is built
locally on the AMPs. The size of Spool 3 is estimated with low
confidence to be 8 rows (170,848 bytes). The estimated time for
this step is 0.16 seconds. 5) Finally, we send out an END
TRANSACTION step to all AMPs involved in processing the request.
-> The contents of Spool 3 are sent back to the user as the result
of statement 1. The total estimated time is 0.32 seconds.
<-- END EXPLAIN FOR REMOTE QUERY >
The size of Spool 1 is estimated with low confidence to be 80,000
rows (2,800,000 bytes). The estimated time for this step is 0.13
seconds.
2) Next, we do an all-AMPs RETRIEVE step from Spool 1 (Last Use) by
way of an all-rows scan with a condition of ("table1.X2 < '012 '")
into Spool 2 (group_amps), which is built locally on the AMPs.
The size of Spool 2 is estimated with no confidence to be 80,000
rows (3,360,000 bytes). The estimated time for this step is 0.54
seconds.
3) Finally, we send out an END TRANSACTION step to all AMPs involved
in processing the request.
-> The contents of Spool 2 are sent back to the user as the result of
statement 1. The total estimated time is 0.67 seconds.
listen_timeout
The number of seconds to wait for one connection while listening. The default is 60
seconds. This value represents the time period in which the query is parsed, runs on the
foreign server, and returns results to the local system. If you are accessing large tables
on the foreign server, you may want to increase this value to avoid having queries time
out.
Users can override this server value at the query level by using a session
QUERY_BAND name value pair. For example:
SET QUERY_BAND = 'listen_timeout=180;' FOR SESSION;
port
The local port number to which the foreign server can connect. This port must remain
open. The default is 5001. If you run any other application that listens on port 5001, you
must specify a different port number in the CREATE or ALTER FOREIGN SERVER
statement.
Note: This NVP is an exception to the rule that you do not use surrounding
apostrophes (single quotation marks) for name value pairs that are composed entirely
of integers. You must delimit the port value with apostrophes.
For example, following is the correct syntax for a port number:
port ('6001')
read_timeout
The number of seconds to wait on the socket. The default value is 30.
Users can override this server value at the query level by using a session
QUERY_BAND name value pair. For example:
SET QUERY_BAND = 'read_timeout=60;' FOR SESSION;
Teradata Database-to-Teradata Aster
39
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE FOREIGN SERVER
schemaname
The name of the schema to use when you import or export queries.
The Teradata-to-Aster connector supports and passes the following server name value pairs
to the Teradata Aster system:
• local_ips
• read_timeout
• port
If a user uses SET QUERY_BAND to set any of these values for a session, then the
QUERY_BAND values take precedence over the values that were set when a foreign server
object was created or last altered.
Import Operator
DO IMPORT WITH
Associates an IMPORT table operator with a foreign server.
Export Operator
DO EXPORT WITH
Associates an EXPORT table operator with a foreign server.
Operator Option
database_name.
The name of the database that contains the operator that you want to call. If you use
LOAD_TO_ASTER or LOAD_FROM_ASTER, the database_name must be SYSLIB.
table_operator
The name of the table operator to use. These table operators are used to import and
export the data between Teradata Database and Teradata Aster systems.
Teradata supplies the following table operators for use with the Teradata-to-Aster
connector:
• LOAD_FROM_ASTER
• LOAD_TO_ASTER
The LOAD_FROM_ASTER operator retrieves data from a Teradata Aster Database for
use in a local Teradata Database, where the data can be placed in tables or joined with
existing tables. It produces a spooled table that contains the specified data from the
remote system. The query that you use can be part of a larger query and can be joined
against Teradata Database tables and views. The data is imported in parallel from
multiple nodes into multiple Teradata Database AMPs.
The LOAD_TO_ASTER operator exports data from Teradata Database to existing
Teradata Aster tables. The data can then be used in subsequent queries from the
Teradata Database or in Teradata Aster queries.
The Teradata-to-Aster connector also includes the SYSLIB.efsspop table operator that
you can associate with a foreign server object so that you can use the
ExecuteForeignSQL syntax to run basic SQL queries on a remote Teradata Aster server.
For information about this table operator, see ExecuteForeignSQL.
Note: These table operators cannot be invoked directly.
40
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE FOREIGN SERVER
Supported Data Types
The following table shows the data types supported by the Teradata-to-Aster connector and
how they are mapped during import and export.
Teradata Data Type
Aster Data Type
Array
Varchar(n)
BigInt
BIGINT
ByteInt
Boolean
Byte[(n)]
ByteA
Char[(n)]
Char[(n)]
bit[(n)]
CHAR_DT
bit
Date
Date
Decimal[(s[,p])]
Numeric(s,p)
Float/Real
Real/Double precision
Integer
Integer
Number
Numeric(s,p)
SMALLINT
SMALLINT
Time (with time zone)
Time (with/without time zone)
Timestamp (with time zone)
Timestamp (with/without time zone)
Varbyte(n)
Bytea
VARBYTE_DT
bytea
VARCHAR(n)
Character varying(n)/varchar(n)
character varying
bit varying(n)
bit varying
Varchar(n)
Interval, ip*, uuid
VARCHAR_DT
bit varying
No Aster type is mapped to Teradata type BYTE_DT.
You cannot cast Teradata CHAR or VARCHAR to Teradata BYTE or VARBYTE.
The following data types are not supported:
• Period
• UDT, such as XML
• Geospatial
• BLOB
Teradata Database-to-Teradata Aster
41
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE FOREIGN SERVER
• CLOB
• JSON
Mapping Aster Numeric to Teradata Decimal and Number
Aster Numeric(p) or Numeric(p,s) where p is less than 38 is mapped to TD Decimal. If p is
equal to or greater than 38, it is mapped to TD Number type, as in the following list:
• Aster Numeric is mapped to TD Number(*,*)
• Aster Numeric(p) or Numeric(p,0) where p is greater than 38 is mapped to TD Number(*,
0)
• Aster Numeric(p,s) where p is greater than 38 is mapped to TD Number(*,s) for s less
than or equal to 38 and mapped to TD Number(*,*) for s greater than 38.
Required Privileges
You must have CREATE SERVER privilege on the TD_SERVER_DB database to define a
foreign server object. If you are associating the server with table operators, you must also
have EXECUTE FUNCTION and SELECT privileges on the specified table operators.
Examples of Creating a Foreign Server
To create a functional foreign server object, you must have at a minimum the following name
value pairs:
• hosttype
• remotehost
• local_ips or ip_device
Note: The default port for the Teradata-to-Aster connector is 5001. If you run any other
application that listens on port 5001, you must also specify a different port number in the
CREATE FOREIGN SERVER statement.
To import and export data, you also need to associate the import and export table operators,
LOAD_FROM_ASTER and LOAD_TO_ASTER, with the foreign server.
This example demonstrates creating a basic Teradata Aster foreign server to use in Teradata
Database. It uses the INVOKER keyword for authorization, which indicates that the
associated authorization credentials must be present in the user’s database at the time that
they access the foreign server. Each user of the foreign server either needs to create an
authorization object that is located in their own user database, or a DBA can create an
authorization object for each user. If users create their own objects, then the DBA does not
need to know their login credentials.
create authorization AsterInvoker AS INVOKER
TRUSTED user 'proxyuser' password 'secret';
After you create the authorization object, then you create the foreign server:
CREATE FOREIGN SERVER AsterServer
EXTERNAL SECURITY INVOKER TRUSTED AsterInvoker
USING
remotehost('198.51.100.9')
hosttype('aster')
42
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
CREATE FOREIGN SERVER
local_ips('192.0.2.24,192.0.2.25')
port('6001')
listen_timeout(240)
read_timeout (60 )
concurrentstreams(1)
DO IMPORT WITH SYSLIB.LOAD_FROM_ASTER,
DO EXPORT WITH SYSLIB.LOAD_TO_ASTER ;
The following example demonstrates creating a Teradata Aster foreign server that uses an
authorization object in Teradata Database. First, you create the authorization object, using
DEFINER to make the authorization globally available:
create authorization TD_SERVER_DB.REMOTE_SQLA_USER AS DEFINER
TRUSTED user 'proxyuser' password 'secret';
Next, you create the foreign server:
CREATE FOREIGN SERVER TD_SERVER_DB.aster_server
EXTERNAL SECURITY DEFINER TRUSTED REMOTE_SQLA_USER
USING
hosttype ('aster')
port ('6001')
remotehost ('my_queen_ip')
local_ips ('my_local_ip')
listen_timeout (60)
read_timeout (60)
concurrentStreams (1)
ByteCountReportFreq (640000)
DO IMPORT WITH SYSLIB.LOAD_FROM_ASTER,
DO EXPORT WITH SYSLIB.LOAD_TO_ASTER ;
Usage Notes
• The target platform of the foreign server object must be running and reachable when you
create the foreign server object for it in Teradata Database.
• You can create multiple named foreign server objects that reference the same server using
the same IP and port numbers.
• Name value pairs in the server area of the syntax apply to the connection to the remote
platform and to both of the table operators specified in the IMPORT WITH and
EXPORT WITH clauses.
• Name value pairs in the IMPORT WITH or EXPORT WITH clause apply only to the
table operator specified in the clause.
• Server options, names, and name value pairs can appear only once in the CREATE
FOREIGN SERVER syntax.
• The order of the DO IMPORT WITH and DO EXPORT WITH clauses in the CREATE
SERVER syntax does not matter.
• You must grant SELECT, INSERT, and SHOW privileges on foreign server objects to
users who need to query foreign server objects.
You cannot use the following names in the name value pairs in CREATE SERVER
statements:
• Columns
Teradata Database-to-Teradata Aster
43
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
DROP FOREIGN SERVER
• hExplain
• IsNested
• Servermode
DROP FOREIGN SERVER
Purpose
Drops a foreign server object from the TD_SERVER_DB database.
In addition to deleting the server object and its associated information from the dictionary
tables, all dependent entries on the associated table operators are deleted.
You must have the DROP SERVER privilege on the TD_SERVER_DB database or on the
specified foreign server to DROP the foreign server.
Syntax
DROP FOREIGN SERVER
server_name
TD_SERVER_DB.
;
Syntax Elements
server_name
The name of the foreign server object.
You can also use the following formats for the server name:
• the Unicode Delimited Identifier, such as U&"foreign#005fsv" UESCAPE'#'
• the double-quoted object name, such as "foreign srv1"
TB_SERVER_DB.
The name of the database that stores server objects and their attributes.
END LOGGING
Purpose
Ends the auditing of SQL requests that started with a BEGIN LOGGING request.
This topic describes only the portions of the END LOGGING syntax diagram that are
specific to Teradata QueryGrid. For information about the other syntax that you can use with
END LOGGING, see SQL Data Definition Language - Syntax and Examples, B035-1144.
44
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
END LOGGING
Syntax
ON
END LOGGING
DENIALS
ALL
,
WITH TEXT
A
operation
GRANT
A
B
FOR CONSTRAINT
,
constraint_name
BY
database_name
user_name
B
,
ON
;
20
AUTHORIZATION authorization_name
DATABASE database_name
USER database_name
TABLE
object_name
VIEW
database_name.
MACRO
user_name.
PROCEDURE
FUNCTION
TYPE
FOREIGN SERVER
Syntax Elements
ON operation
Indicates the operation for which log entries should no longer be made.
ON FOREIGN SERVER object_name
Indicates that the operation for which log entries should no longer be made is access to
a foreign server.
You must specify an object name, which is the name of the foreign server. You can
optionally specify the name of the containing database, which must be
TD_SERVER_DB. You cannot use a user_name with FOREIGN SERVER.
For information about using END LOGGING, see SQL Data Definition Language - Syntax
and Examples, B035-1144.
Teradata Database-to-Teradata Aster
45
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
ExecuteForeignSQL
ExecuteForeignSQL
Purpose
A stored procedure that provides a simple interface for executing basic SQL queries, such as
CREATE, DROP, DELETE, and GRANT on a foreign server. For example, you can use
ExecuteForeignSQL to create or drop a table in a database on the foreign server.
ExecuteForeignSQL passes all SQL queries through, but it does not return results sets, so if
you use it to execute a SELECT or HELP statement, you do not see any results.
Syntax
CALL
ExecuteForeignSQL
(
‘query_expression’ , ‘server_name’
)
;
SYSLIB.
Syntax Elements
SYSLIB.
The name of the database where the stored procedure is located.
query_expression
A valid Teradata Aster SQL query.
The query is passed through unparsed to the foreign server.
server_name
The name of the foreign server.
Usage Notes
ExecuteForeignSQL provides secure execution by using an embedded table operator along
with Trusted Sessions to handle logon credential verification.
A DBA can selectively GRANT the privilege to use ExecuteForeignSQL.
To call ExecuteForeignSQL, you must first create a foreign server object that specifies DO
IMPORT WITH SYSLIB.EFSSPOP_TDSQLT.
You must have EXECUTE FUNCTION and SELECT privileges on this operator. You can
only associate one import operator at a time with a foreign server, so to run
ExecuteForeignSQL on an existing foreign server that is being used for queries, you can
create a separate foreign server object with a different name to use for running
ExecuteForeignSQL.
If you reference a table name, you must prepend it with the schema name.
SQL queries that return result sets, such as SELECT or HELP, are executed on the remote
system, but the resultant rows are not displayed. The query may continue to use CPU,
memory and I/O resources on the remote system.
ExecuteForeignSQL uses a proxyuser, so the execution of commands on behalf of DBC is not
supported.
46
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
GRANT and REVOKE
Examples of Using ExecuteForeignSQL
Before you can call ExecuteForeignSQL, you must create the foreign server object and
specify DO IMPORT WITH SYSLIB.EFSSPOP_TDSQLT. For example:
CREATE FOREIGN SERVER TD_SERVER_DB.remote_aster_system
EXTERNAL SECURITY DEFINER TRUSTED remote_aster_system_proxy
USING
hosttype ('Aster')
remotehost ('198.51.100.15')
local_ip ('198.51.100.24')
DO IMPORT WITH SYSLIB.EFSSPOP_TDSQLT;
The example that follows creates a table on the foreign server:
CALL SYSLIB.ExecuteForeignSQL('CREATE TABLE testdb.Store(Str_Cd
integer, Str_Nm varchar(10))
DISTRIBUTE BY HASH (Str_Cd);','remote_aster_system');
GRANT and REVOKE
GRANT grants one or more explicit privileges on a database, foreign server, user, proxy
logon user, table, hash index, join index, view, stored procedure, User-Defined Function
(UDF), User-Defined Method (UDM), User-Defined Type (UDT), or macro to a role, group
of roles, user, or group of users or databases. REVOKE revokes privileges on the same
objects.
There are no changes to existing syntax for Teradata QueryGrid, except that CREATE
SERVER and DROP SERVER privileges have been added. These privileges should be granted
only to a user, not to a database.
For a syntax diagram and description of the syntax elements that you can use in GRANT
and REVOKE, see SQL Data Control Language, B035-1149.
HELP FOREIGN
Purpose
Returns the details of the foreign object that you specify.
• A foreign server object name returns the list of databases accessible on the specified
server.
• The name of a database on a foreign server returns the list of available schemas in the
remote database.
• The name of a table on a foreign server returns the list of column names and types for the
table.
Teradata Database-to-Teradata Aster
47
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
HELP FOREIGN
Syntax
Syntax Elements
SERVER server_name
The name of the foreign server.
DATABASE db_name@server_name
The name of the remote database.
TABLE schema_name.table_name@server_name
The name of the remote table, optionally qualified with the name of the schema. If no schema
name is specified, the default schema for the logged-in user on the Teradata Aster server is
used.
Required Privileges
You must have any access privilege on the foreign server object to display the output of HELP
FOREIGN statements. If the specified database or table name does not exist on the foreign
server, then behavior is determined by the import table operator.
Any user, including the DBA user and end users, can use HELP FOREIGN statements if they
have been granted any privilege, such as SELECT, INSERT, SHOW or ALL, to the foreign
server object. The results are restricted to the access rights of the user that is defined and
authenticated on the Teradata Aster system.
Examples of Using HELP FOREIGN
Using HELP FOREIGN SERVER
The following example illustrates the use of HELP FOREIGN SERVER:
HELP FOREIGN SERVER AsterServer;
DatabaseName
DatabaseOwner
------------------------------ ----------------------------beehive
beehive
my_db
db_superuser
Using HELP FOREIGN DATABASE
The following example illustrates the use of HELP FOREIGN DATABASE:
48
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
SHOW FOREIGN SERVER
HELP FOREIGN DATABASE beehive@AsterServer;
Schemaname
SchemaOwner
------------------------------ -----------------------------nc_temp_1
db_superuser
public
beehive
nc_system
db_admin
nc_temp_7
db_superuser
nc_temp_8
db_superuser
nc_temp_3
db_superuser
nc_temp_10
db_superuser
nc_temp_12
db_superuser
nc_temp_11
db_superuser
nc_temp_14
db_superuser
nc_temp_13
db_superuser
nc_temp_15
db_superuser
nc_temp_16
db_superuser
nc_temp_9
db_superuser
myschema
db_superuser
nc_temp_17
db_superuser
Using HELP FOREIGN TABLE
The following example illustrates the use of HELP FOREIGN TABLE:
HELP FOREIGN TABLE myschema.tab1@AsterServer;
colname
coltype
isinherited
i
integer
j
character varying
isnotnull
ispartitionkey
0
0
1
0
0
0
SHOW FOREIGN SERVER
Purpose
Displays the SQL text most recently used to create, drop, or modify the server object.
A SHOW FOREIGN SERVER statement allows you to see a server object definition that
contains the name value pairs that the associated table operators use to connect to the
foreign server.
Syntax
SHOW
FOREIGN SERVER
IN XML
Teradata Database-to-Teradata Aster
server_name
TB_SERVER_DB.
;
49
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
SHOW FOREIGN SERVER
Syntax Elements
IN XML
To return the report in XML format.
The XML schema for the output produced by this option is maintained in:
http://schemas.teradata.com/dbobject/DBobject.xsd
TB_SERVER_DB.
The name of the database that stores foreign server objects and their parameters.
server_name
The name of the foreign server object.
For the full syntax diagram and information about the other objects that can be used with
SHOW, see SQL Data Definition Language - Syntax and Examples, B035-1144.
Required Privileges
SHOW FOREIGN SERVER requires SHOW privilege or ANY privilege on the server object
to display the output.
Example of Using SHOW FOREIGN SERVER Syntax
SHOW FOREIGN SERVER remote_system ;
This query generates the following output:
----------------------------------------------------------------------CREATE FOREIGN SERVER TD_SERVER_DB.remote_system
EXTERNAL SECURITY DEFINER TRUSTED remote_system_proxy USING
Hosttype ('Aster')
remotehost ('198.51.100.15')
local_ips ('192.0.2.24')
port ('6001')
read_timeout (200)
listen_timeout (60)
concurrentstreams (2)
DO IMPORT WITH SYSLIB.LOAD_FROM_ASTER,
DO EXPORT WITH SYSLIB.LOAD_TO_ASTER ;
50
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Using the Teradata-to-Aster Connector with SELECT Statements
Using the Teradata-to-Aster Connector with
SELECT Statements
There are several ways that you can execute queries on a remote Teradata Aster system from
a Teradata Database system, if you have the appropriate privileges.
Using a SELECT Statement
You can use the foreign server grammar in the form of schema_name.
table_name@foreign_server_name in a SELECT statement to reference a table on a specified
foreign server or to specify a pass-through query to be executed on the foreign server. The
reference to the external table calls the IMPORT table operator that is associated with the
foreign server definition.
SELECT * from schema_name.table_name@foreign_server_name
Using a Pass Through Query
You can use the FOREIGN TABLE keyword to indicate that a query is to be passed through
and executed on the Teradata Aster system.
SELECT * from FOREIGN TABLE (SELECT count(col1) from t1 group by
col2)@AsterSystem as dt;
Using the AsterExecute Table Operator to Execute an Aster Analytical
Function
Using the AsterExecute table operator, you can execute a function in a SELECT statement,
just as you execute any other table operator defined on the Teradata system. Using a
keyword, RemoteQuery, Teradata identifies the function as a foreign function, exports the
specified input data onto the Teradata Aster foreign server, executes the function there, and
then returns the results.
The next example uses the following table:
CREATE SET TABLE clickstream ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
partition_id INTEGER,
uid INTEGER,
clicktime TIMESTAMP(6),
pname VARCHAR(10) CHARACTER SET LATIN NOT CASESPECIFIC,
pagetype VARCHAR(10) CHARACTER SET LATIN NOT CASESPECIFIC,
referrer VARCHAR(30) CHARACTER SET LATIN NOT CASESPECIFIC,
pprice DECIMAL(10,2))
PRIMARY INDEX ( p1 );
partition_id
1
uid
1234
clicktime
2014-01-01 09:50:55.000000
Teradata Database-to-Teradata Aster
pname
Bob A TV
pagetype
checkout
referrer
I.comp.com
pprice
2,000.00
51
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Using the Teradata-to-Aster Connector with SELECT Statements
1
1
1
1
1
1
1
1
1
1
1
1234
1234
1234
567
567
567
567
777
777
777
777
2014-01-01
2014-01-01
2014-01-01
2014-01-05
2014-01-05
2014-01-05
2014-01-05
2014-01-05
2014-01-05
2014-01-05
2014-01-05
09:50:55.500000
09:50:56.000000
10:10:10.000000
09:50:55.000000
09:50:55.500000
09:50:56.000000
10:10:10.000000
09:50:55.000000
09:50:55.500000
09:50:56.000000
10:10:10.000000
Joe
Flo
Ann
Bob
Joe
Flo
Ann
Bob
Joe
Flo
Ann
B
C
D
A
B
C
D
A
B
C
D
TV
TV
TV
TV
TV
TV
TV
TV
TV
TV
TV
checkout
checkout
checkout
checkout
checkout
checkout
checkout
checkout
checkout
checkout
checkout
I.comp.com
I.comp.com
I.comp.com
I.comp.com
I.comp.com
I.comp.com
I.comp.com
I.comp.com
I.comp.com
I.comp.com
I.comp.com
8,500.00
5,000.00
2,500.00
2,000.00
8,500.00
5,000.00
2,500.00
2,000.00
8,500.00
5,000.00
2,500.00
The example query is as follows:
SELECT * FROM AsterExecute(
ON clickstream
@aster_server
USING
RemoteQuery('SELECT * FROM SESSIONIZE(
ON %s
partition by("partition_id") order by("partition_id ")
timecolumn("clicktime") timeout("3000"))')
substitute(' " -> '' ')
) AS DT;
Following is a more complex example that executes the Teradata Aster nPath analytical
function on a Teradata Aster server and returns the results to the Teradata system. Note that
the number of instances of %s equals the number of ON clauses in the first SELECT
statement. Note also that the tv_spots table in this example is located is on a different
Teradata Aster server (AsterSystem) from the Teradata Aster server where nPath is executed
on the input data set (aster_server1).
SELECT * FROM AsterExecute
(
on (select * from td_clicks) partition by p1
on (select * from testdb.tv_spots@AsterSystem) partition by p1
@aster_server1
USING
REMOTEQUERY('select * from npath
(on impressions partition by uid order by ctime
on %s partition by uid order by ctime
on %s dimension order by ctime
mode (nonoverlapping)
symbols (true as imp, true as click , true as tv_imp)
pattern ("(imp|tv_imp)*.click")
result (count(* of imp)as imprcount, count(* of
tv_imp) as tvcount))'
)
SUBSTITUTE(' "->'") ) AS DT;
In the following example, the AsterExecute table operator retrieves data from a remote
Teradata system and exports it to an Aster server to run a Teradata Aster analytical function.
It then returns the results to the local Teradata system.
52
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Using the Teradata-to-Aster Connector with SELECT Statements
SELECT * from asterexecute
(
ON (SELECT * from td_impressions_empty) partition by p1
ON (SELECT * from td_clicks@Remote_Teradata_Server) partition by p1
@aster_server
USING
REMOTEQUERY(
'SELECT * from npath(
ON %s partition by uid order by ctime
ON %s partition by uid order by ctime
ON testdb.tv_spots dimension order by ctime
mode (nonoverlapping)
symbols (true as imp, true as click, true as tv_imp)
pattern ( "(imp|tv_imp)*.click")
result (count(* of imp)as imprcount,
count(* of tv_imp) as tvcount))')
) as dt;
Support for Using a RETURNS Clause
For Aster columns of bit or bit varying type, which map to a Teradata char or varchar, you
can specify a RETURNS clause using char or varchar and unicode or Latin combinations
with different lengths.
For Aster columns of bytea type, which map to the Teradata data type varbyte, you can
specify a RETURNS clause using varbyte or byte of various lengths. Note that even if you
specify a Teradata byte type in the RETURNS clause, it is still mapped to the varbyte type.
One benefit of using a RETURNS clause is to specify to return a smaller data length to
reduce the total amount of data you bring into Teradata from Aster.
The following examples illustrate the use of the RETURNS clause:
select c1,c2,type(c1),type(c2) from testdb.at1@astersrv RETURNS(c2
char(3) character set
unicode);
This query returns the following result:
*** Query completed. 6 rows found. 4 columns returned.
*** Total elapsed time was 3 seconds.
c1
c2
Type(c1)
Type(c2)
c1
c2
Type(c1)
Type(c2)
c1
c2
Type(c1)
Type(c2)
Teradata Database-to-Teradata Aster
2
Tue
INTEGER
CHAR(3) CHARACTER SET UNICODE
1
Mon
INTEGER
CHAR(3) CHARACTER SET UNICODE
3
Wed
INTEGER
CHAR(3) CHARACTER SET UNICODE
53
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Using the Teradata-to-Aster Connector with INSERT Statements
c1
c2
Type(c1)
Type(c2)
c1
c2
Type(c1)
Type(c2)
c1
c2
Type(c1)
Type(c2)
5
Fri
INTEGER
CHAR(3) CHARACTER SET UNICODE
5
Fri
INTEGER
CHAR(3) CHARACTER SET UNICODE
5
Fri
INTEGER
CHAR(3) CHARACTER SET UNICODE
The second query is as follows:
select a,b,c,type(b),type(c) from testdb.tab_bit@astersrv RETURNS(b
varchar(2) character set unicode, c varchar(2) character set latin);
The second query yields the following results:
*** Query completed. One row found. 5 columns returned.
*** Total elapsed time was 3 seconds.
a
b
c
Type(b)
Type(c)
1
10
10
VARCHAR(2) CHARACTER SET UNICODE
VARCHAR(2)
The LOB data type is not supported.
For more information about the supported data types, see Supported Data Types.
Usage Notes
• If you do not qualify a Teradata Aster table or function with a schema name in the
SELECT statement, it defaults to the current Teradata Database name.
• You can SELECT any combination of the supported data types.
For a list of the supported data types, see Supported Data Types.
• You can use this foreign server grammar in joins and any other place that you reference a
normal table, including views, macros, and stored procedures.
• Logical expressions such as AND, OR, NOT, >, <, and so on, are supported.
• The standard Teradata limits, such as returning up to 2048 columns, apply. Row size must
be less than 64K.
Using the Teradata-to-Aster Connector with
INSERT Statements
If you have the appropriate privileges, you can use a standard INSERT statement in the
following form with the Teradata-to-Aster connector:
54
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Using the Teradata-to-Aster Connector with INSERT Statements
INSERT INTO schema_name.table_name@foreign_server_name SELECT *
FROM ...
You can also specify columns to insert as follows:
INSERT INTO schema_name.table_name@foreign_server_name(Col1, Col2)
SELECT * FROM ...
You can also insert values as follows:
INSERT INTO schema_name.table_name@foreign_server_name (value1, value2)
You can insert any combination of the supported data types.
An Example of Using INSERT to Export Data
You can export data to the remote system by using an INSERT statement to place data into
an existing table. The table can be empty or it can contain data. If the table already contains
data, the exported data is appended to the existing table’s data.
INSERT INTO STORE.Item_Price@remote_system
SELECT m.item_no, 0.00
FROM STORE.Item_Master m
WHERE m.item_no NOT IN (SELECT item_no
FROM STORE.Item_Price@remote_system) ;
You can insert specific named columns into a remote table as well as constant data, as
demonstrated in the following query:
INSERT INTO STORE.Item_Price@remote_system VALUES(2501,27.99) ;
Using EXPLAIN to Understand INSERT Queries
You can use an EXPLAIN to describe how remote queries are handled. For example,
consider the following query:
explain insert into testdb.at1@astersrv select * from t1;
This query returns the following output:
*** Help information returned. 45 rows.
*** Total elapsed time was 17 seconds.
Explanation
--------------------------------------------------------------------------1) First, we lock a distinct SQLA_USER."pseudo table" for read on a
RowHash to prevent global deadlock for SQLA_USER.t1.
2) Next, we lock SQLA_USER.t1 for read.
3) We do an all-AMPs RETRIEVE step from SQLA_USER.t1 by way of an
all-rows scan with no residual conditions executing table operator
SYSLIB.load_to_aster with a condition of ("(1=1)") into Spool 2
(used to materialize view, derived table, table function or table
operator at1) (all_amps), which is built locally on the AMPs.
< BEGIN EXPLAIN FOR REMOTE QUERY -->
Teradata Database-to-Teradata Aster
55
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Using EXPLAINs with Remote Queries
Number=1, Statement=Sqlmr Function:
nc_system.load_from_remote_td Result Table: _tmp_0 Input Query:
SELECT ("c1") :: integer AS "c1", ("c2") :: character varying(20)
AS "c2" FROM "testdb"."at1" AS "projInp_" Supports Collaborative
Planning: false , Result Table=, Statement Type=Sqlmr,
Location=All Workers, Query Plan and Estimates=null, Data Size
Distribution (in bytes)=null
Number=2, Statement=Target Table: "_tmp_1" Statement: SELECT "c1"
AS "c1", "c2" AS "c2" FROM "_tmp_0" AS "projInp_" , Result
Table=, Statement Type=Materialize, Location=All Workers, Query
Plan and Estimates=localCost=0.00..12.50 rows=3000 width=62
networkCost=181 Function Scan on bridge (cost=0.00..12.50
rows=1000 width=62) , Data Size Distribution (in bytes)=mean
size=62000 standard deviation=0
Number=3, Statement=Source Data Distribution: Workers Partitioned
with partitioning column(s) unknown Destination Data Distribution:
Workers Partitioned on column(s)[c1] Result Table:
"testdb"."at1" Attributes: "Materialize": "true", Source Query:
SELECT "c1" AS "c1", "c2" AS "c2" FROM "_tmp_1" AS "final_" ,
Result Table=, Statement Type=DataTransfer, Location=All Workers,
Query Plan and Estimates=localCost=0.00..31.00 rows=9000 width=62
networkCost=544 Seq Scan on _tmp_1 final_ (cost=0.00..31.00
rows=3000 width=62) , Data Size Distribution (in bytes)=mean
size=186000 standard deviation=0
<-- END EXPLAIN FOR REMOTE QUERY >
The size of Spool 2 is estimated with low confidence to be 4 rows
(156 bytes). The estimated time for this step is 0.08 seconds.
4) We do an all-AMPs RETRIEVE step from Spool 2 (Last Use) by way of
an all-rows scan into Spool 3 (Last Use), which is built locally
on the AMPs. The size of Spool 3 (Last Use) is estimated with low
confidence to be 4 rows (284 bytes). The estimated time for this
step is 0.08 seconds.
5) Finally, we send out an END TRANSACTION step to all AMPs involved
in processing the request.
-> No rows are returned to the user as the result of statement 1.
The total estimated time is 0.16 seconds.
Using EXPLAINs with Remote Queries
You can use an EXPLAIN to return the EXPLAIN plan for remote query execution. You can
see the cost estimates associated with each phase and estimates of how the data is distributed
across worker nodes. Data for each row is retrieved and concatenated in a string column
from the output of the remote query EXPLAIN on the Teradata Aster system. For example,
suppose you have the following query:
explain select * from testdb.at1@astersrv;
This query produces the following result:
*** Help information returned. 40 rows.
*** Total elapsed time was 21 seconds.
56
Teradata Database-to-Teradata Aster
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Using EXPLAINs with Remote Queries
Explanation
--------------------------------------------------------------------------1) First, we do an all-AMPs RETRIEVE step executing table operator
SYSLIB.load_from_aster with a condition of ("(1=1)").
< BEGIN EXPLAIN FOR REMOTE QUERY -->
External Query: SELECT c1 ,c2 FROM testdb.at1
Number=1, Statement=Sqlmr Function:
nc_system.load_to_remote_td Result Table: _tmp_0 Input Query:
SELECT ("c1") :: integer AS "c1", ("c2") :: character varying(20)
AS "c2" FROM "testdb"."at1" AS "projInp_" Supports Collaborative
Planning :false , Result Table=, Statement Type=Sqlmr,
Location=All Workers, Query Plan and Estimates=null, Data Size
Distribution (in bytes)=null
Number=2, Statement=Source Data Distribution: Workers Partitioned
with partitioning column(s) unknown Destination Data Distribution:
Queen Result Table: "_tmp_1" Attributes: "Materialize":
"false", Source Query: SELECT "c1" AS "c1", "c2" AS "c2" FROM
"_tmp_0" AS "projInp_" , Result Table=, Statement
Type=DataTransfer, Location=All Workers, Query Plan and
Estimates=localCost=0.00..12.50 rows=3000 width=62
networkCost=181 Function Scan on bridge (cost=0.00..12.50
rows=1000 width=62) , Data Size Distribution (in bytes)=mean
size=62000 standard deviation=0
Number=3, Statement=SELECT "c1" AS "c1", "c2" AS "c2" FROM
"_tmp_1" AS "final_", Result Table=, Statement Type=Query,
Location=Queen, Query Plan and Estimates=localCost=0.00..45.50
rows=3550 width=62 networkCost=0.00 Seq Scan on _tmp_1 final_
(cost=0.00..45.50 rows=3550 width=62) , Data Size Distribution (in
bytes)=mean size=220100 standard deviation=0
<-- END EXPLAIN FOR REMOTE QUERY >
The size of Spool 1 is estimated with low confidence to be 40,000
rows (1,600,000 bytes). The estimated time for this step is 0.06
seconds.
2) Next, we do an all-AMPs RETRIEVE step from Spool 1 (Last Use) by
way of an all-rows scan into Spool 2 (group_amps), which is built
locally on the AMPs. The size of Spool 2 is estimated with no
confidence to be 40,000 rows (2,080,000 bytes). The estimated
time for this step is 0.25 seconds.
3) Finally, we send out an END TRANSACTION step to all AMPs involved
in processing the request.
-> The contents of Spool 2 are sent back to the user as the result of
statement 1. The total estimated time is 0.32 seconds.
Teradata Database-to-Teradata Aster
57
Chapter 3 Syntax for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Using EXPLAINs with Remote Queries
58
Teradata Database-to-Teradata Aster
CHAPTER 4
Administration of Teradata QueryGrid: Teradata
Database-to-Teradata Aster Database
Archive and Restore
Database DBC.TD_SERVER_DB stores all the database objects created using the QueryGrid
connector. Note the following about archiving or restoring this database:
• Archive and restore TD_SERVER_DB as a user database. It is not archived and restored
as part of DBC.
• You can archive and restore the entire database or individual objects in the database.
• Teradata archives the associated rows from DBC.ServerInfo and DBC.ServerTblOpInfo
at the same time as it archives TD_SERVER_DB.
• The post-restore script validates server connectivity.
Note the following about copying foreign server objects:
• Users lose their privileges on a foreign server object after it is copied, so administrators
must grant these privileges again.
• You can copy the entire TD_SERVER_DB database or individual objects in the database.
Renaming is not allowed.
Teradata Database-to-Teradata Aster
59
Chapter 4 Administration of Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Archive and Restore
60
Teradata Database-to-Teradata Aster
CHAPTER 5
Data Dictionary Tables and Views for Teradata
QueryGrid: Teradata Database-to-Teradata
Aster Database
Introduction to the Data Dictionary Views and
Tables
Data Dictionary tables are reserved for system use. A few of the Data Dictionary tables
contain metadata about the foreign servers defined on the Teradata Database system. These
tables can be accessed only by users who have the required privileges to the tables. Access to
the tables is strictly controlled to ensure that users, including system administrators, cannot
modify them.
The Data Dictionary data can also be populated in Data Dictionary views. You can retrieve
frequently-used data from any of the Data Dictionary tables via pre-defined views. The
Teradata database administrator determines the set of views available to a user.
The Data Dictionary views each have an equivalent X version. For example, for the ServerV
view, there is also an X version of that view. The X version of the view limits the view to only
those server objects to which the user selecting from the view has access. For more
information about X and VX views (also referred to as Unicode views), see Data Dictionary,
B035-1092.
Notice: To ensure that the system functions properly, do not modify or delete any Data Dictionary
tables. Use the Data Dictionary views to access data in the tables to ensure that the tables are
not accidentally modified or deleted.
For information about Data Dictionary Views and Tables, including X and VX views (also
referred to as Unicode views), and examples of querying Data Dictionary views, see Data
Dictionary, B035-1092.
The views presented here are in alphabetical order for quick reference to the meaning of
individual fields. The actual Data Dictionary tables and view fields do not appear in
alphabetical order.
Displaying the View and Table Definitions
To display the view or table definitions, execute SHOW VIEW or SHOW TABLE
objectname, where objectname is the name of the view or table whose most recent SQL create
Teradata Database-to-Teradata Aster
61
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Data Dictionary Views
text is to be reported. For details on using the SHOW VIEW or SHOW TABLE statement, see
Data Dictionary, B035-1092 or Database Administration, B035-1093.
Teradata-to-Aster Connector Data Dictionary
Views
QryLogV
Category
Query
Database
DBC
View Column and Referenced Table.Column
View Column
Data Type
Format
Referenced Table.Column
TotalServerByteCount
FLOAT
----,---,---,---,--9
DBQLogTbl.TotalServerByteCount
Usage Notes
This DBQL view of the DBQLogTbl table reports things such as the AMP using the most
CPU, the AMP with the most I/O, or maximum amount of spool used when processing a
query. It can also report the size of the data transferred between Teradata and a foreign
server.
For more information about the QryLogV view, see Data Dictionary, B035-1092.
For more information about the DBQL feature and detailed descriptions about the QryLogV
view, see Database Administration, B035-1093.
TotalServerByteCount Column
The TotalServerByteCount column is the total number of bytes read from or sent to foreign
servers involved in the request.
QryLogStepsV
Category
Query
Database
DBC
62
Teradata Database-to-Teradata Aster
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Data Dictionary Views
View Column and Referenced Table.Column
View Column
Data Type
Format
Referenced Table.Column
ServerByteCount
FLOAT
----,---,---,---,--9
DBQLStepTbl.ServerByteCount
Usage Notes
This view of the DBQLStepTbl table is populated if you specify the WITH STEPINFO
option. When the query completes, the system logs one row for each query step, including
parallel steps.
This view can also show the size of the data transferred between Teradata and a foreign
server for each step.
For more information about the QryLogStepsV view, see Data Dictionary, B035-1092.
For more information about the DBQL feature and a description of the QryLogStepsV view,
see Database Administration, B035-1093.
ServerByteCount Column
The ServerByteCount column is the total number of bytes sent to or received from a foreign
server for each step.
ServerV[X]
Category
Operations
Database
DBC
View Column and Referenced Table.Column
View Column
Data Type
Format
Referenced Table.Column
ServerID
BYTE(6)
X(12)
TVM.TVMId
X(128)
Dbase.DatabaseName
X(128)
TVM.TVMName
X(128)
Dbase.DatabaseName
NOT NULL
DataBaseName
VARCHAR(128)
UNICODE
NOT CASESPECIFIC
NOT NULL
ServerName
VARCHAR(128)
UNICODE
NOT CASESPECIFIC
NOT NULL
CreatorName
VARCHAR(128)
Teradata Database-to-Teradata Aster
63
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Data Dictionary Views
View Column
Data Type
Format
Referenced Table.Column
UNICODE
NOT CASESPECIFIC
NOT NULL
CreateTimeStamp
TIMESTAMP(0)
YYYY-MMDDBHH:MI:SS
TVM.CreateTimeStamp
LastAlterName
VARCHAR(128)
X(128)
Dbase.DatabaseName
UNICODE
NOT CASESPECIFIC
NOT NULL
LastAlterTimeStamp
TIMESTAMP(0)
YYYY-MMDDBHH:MI:SS
TVM.LastAlterTimeStamp
AuthorizationName
VARCHAR(128)
X(128)
TVM.AuthName
X(15)
TVM.AuthorizationType
UNICODE
NOT CASESPECIFIC
AuthorizationType
VARCHAR(15)
UNICODE
NOT CASESPECIFIC
Usage Notes
This Teradata QueryGrid connector Data Dictionary view provides details about the foreign
servers defined in the Teradata Database system.
Possible Values of the AuthorizationType Column
Value
Description
T
Invoker Trusted
S
Definer Trusted
''
Unknown
ServerInfoV[X]
Category
Operations
Database
DBC
64
Teradata Database-to-Teradata Aster
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Data Dictionary Views
View Column and Referenced Table.Column
View Column
Data Type
Format
Referenced Table.Column
NameInfo
VARCHAR(128)
X(128)
ServerInfo.NameInfo
X(7)
ServerInfo.NameInfoType
X(128)
TVM.TVMName
X(256)
ServerInfo.ValueInfo
UNICODE
NOT CASESPECIFIC
NOT NULL
NVPType
VARCHAR(7)
UNICODE
NOT CASESPECIFIC
ServerName
VARCHAR(128)
UNICODE
NOT CASESPECIFIC
NOT NULL
ValueInfo
VARCHAR(32000)
UNICODE
NOT CASESPECIFIC
Usage Notes
This Teradata QueryGrid connector Data Dictionary view provides details about the name
value pairs used by foreign servers defined in the Teradata Database system.
Possible Values of the NVPType Column
•
•
•
•
IMPORT
EXPORT
GLOBAL
UNKNOWN
TblSrvV[X]
Category
Operations
Database
DBC
View Column and Referenced Table.Columns
View Column
Data Type
Format
Referenced Table.Column
ServerName
VARCHAR(128)
X(128)
TVM.TVMName
Teradata Database-to-Teradata Aster
65
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Data Dictionary Views
View Column
Data Type
Format
Referenced Table.Column
X(128)
Dbase.DatabaseName
X(128)
ServerTblOpInfo.TblopName
X(128)
ServerTblOpInfo.TblopDBName
X(7)
ServerTblOpInfo.TblOpType
UNICODE
NOT CASESPECIFIC
NOT NULL
SrvDataBaseName
VARCHAR(128)
UNICODE
NOT CASESPECIFIC
NOT NULL
TblOpName
VARCHAR(128)
UNICODE
NOT CASESPECIFIC
NOT NULL
TblOpDBName
VARCHAR(128)
UNICODE
NOT CASESPECIFIC
NOT NULL
TableOperatorType
VARCHAR(7)
UNICODE
NOT CASESPECIFIC
Usage Considerations
This Teradata QueryGrid connector view returns information about the foreign servers and
their associated table operators.
Possible Values of the TableOperatorType Column
• IMPORT
• EXPORT
• UNKNOWN
TblSrvInfoV[X]
Category
Operations
Database
DBC
66
Teradata Database-to-Teradata Aster
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Data Dictionary Views
View Column and Referenced Table.Column
View Column
Data Type
Format
Referenced Table.Column
ServerName
VARCHAR(128)
X(128)
TVM.TVMName
X(128)
Dbase.DatabaseName
X(128)
ServerTblOpInfo.TblopName
X(128)
ServerTblOpInfo.TblopDBName
X(128)
ServerInfo.NameInfo
X(256)
ServerInfo.ValueInfo
X(7)
ServerTblOpInfo.TblOpType
UNICODE
NOT CASESPECIFIC
NOT NULL
SrvDataBaseName
VARCHAR(128)
UNICODE
NOT CASESPECIFIC
NOT NULL
TblOpName
VARCHAR(128)
UNICODE
NOT CASESPECIFIC
NOT NULL
TbpOpDataBaseName
VARCHAR(128)
UNICODE
NOT CASESPECIFIC
NOT NULL
NameInfo
VARCHAR(128)
UNICODE
NOT CASESPECIFIC
NOT NULL
ValueInfo
VARCHAR(32000)
UNICODE
NOT CASESPECIFIC
TableOperatorType
VARCHAR(7)
UNICODE
NOT CASESPECIFIC
Usage Considerations
This Teradata QueryGrid connector view returns the name value pairs defined for a foreign
server.
Possible Values of the TableOperatorType Column
• IMPORT
• EXPORT
Teradata Database-to-Teradata Aster
67
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Dictionary Tables
• UNKNOWN
Teradata-to-Aster Connector Dictionary Tables
DBC.AccessRights
This Data Dictionary table stores information about discretionary access privileges and rowlevel security privileges that have been granted.
This information includes:
• The ID of the user that was granted the privilege
• The specific privilege that was granted
• Who granted it, and whether it was granted using the GRANT statement
Row Values
Row
Description
AccessRight
The type of privilege granted on a user object only. Possible values
include:
• CS (CREATE SERVER)
• DS (DROP SERVER)
Note: These values must be explicitly granted.
Related Topics
For more information about the DBC.AccessRights table, see Data Dictionary, B035-1092.
DBC.AccLogRuleTbl
This Data Dictionary table stores information about the logging of access privilege checks.
This information includes:
• Typical access control privilege checks
• Row-level security privilege checks
• The user, database, and object involved in the privilege check
Note: For Teradata QueryGrid connector queries, this is the remote object or user on the
foreign server involved in the privilege check.
Row Values
Row
Description
AcrCreateServer
This row stores the logging in effect for the CREATE SERVER
privilege on TD_SERVER_DB to which the rule applies.
This row is populated if you specify the ON FOREIGN SERVER
option in the BEGIN or END LOGGING statement.
68
Teradata Database-to-Teradata Aster
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Dictionary Tables
Row
Description
AcrDropServer
This row stores the logging in effect for the DROP SERVER privilege
on TD_SERVER_DB to which the rule applies.
This row is populated if you specify the ON FOREIGN SERVER
option in the BEGIN or END LOGGING statement.
DBC.DBQLogTbl
This Data Dictionary table is the main DBQL table containing information about the SQL
and Teradata QueryGrid connector queries being logged.
The DBQLogTbl default row consists of all the available DBQLogTbl table fields. The default
row provides general query information that is usually adequate for investigating a query
that is interfering with performance.
When no options are specified, a default row includes:
• User ID and user name under which the session being logged was initiated
• Unique ID for the process, session, and host (client) connection
• Account string, expanded as appropriate, that was current when the query completed
• First 200 characters of the query statement
• CPU and I/O statistics
• Default database name that was current when the query completed
• The total size of the data transferred between Teradata and a foreign server
The default is one default row per query.
Row Values
Row
Description
StatementGroup
If there is a DDL statement in a request, the StatementGroup
column reports which type:
• DDL CREATE if this is a CREATE FOREIGN SERVER
statement
• DDL ALTER if this is an ALTER or DROP FOREIGN SERVER
statement
• OTHER SYS OTHER if this is a SHOW FOREIGN SERVER or
HELP FOREIGN statement
• DDL GRANT
If the statement has only one DML statement or multiple DML
statements that are all of the same type, StatementGroup indicates
the type. For example if there are three DELETE statements in a
request, StatementGroup reports:
DML DELETE
Similarly, for requests with individual or multiple INSERT,
INSERT... SELECT, UPDATE or SELECT statements,
StatementGroup reports:
Teradata Database-to-Teradata Aster
69
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Dictionary Tables
Row
Description
•
•
•
•
DML INSERT
DML INSERT... SELECT
DML UPDATE
SELECT
In a multistatement request with different types of DML statements,
you see a list showing the number of statements of each type in the
request. For example, a request with one insert and two update
statements appears as:
DML Del=0 Ins=1 InsSel=0 Upd=2 Sel=0
StatementType
The type of statement of the query.
In a multistatement request, this is the last statement of the request.
However, this may not accurately describe the request. For more
statement information, see StatementGroup.
The possible values recorded include:
• CREATE SERVER for the CREATE FOREIGN SERVER
statement.
• ALTER SERVER for ALTER FOREIGN SERVER statement.
• DROP SERVER for the DROP FOREIGN SERVER statement.
• SHOW for the SHOW FOREIGN SERVER statement.
• HELP for the HELP FOREIGN statement.
TotalServerByteCount
The total number of bytes read from or sent to a foreign server
object. The column is NULL if the request does not load or send
data from or to a foreign server object.
Related Topics
For more information about the ...
See ...
DBQL feature, how to enable DBQL logging, and Database Administration
the DBC.DBQStepTbl table and fields
B035-1093
BEGIN/REPLACE QUERY LOGGING statement SQL Data Definition Language - Syntax and
Examples
B035-1144
DBC.Dependency
This Data Dictionary table stores information about the relationships and dependencies
between various types of objects. The types of relationships and dependencies include:
• Relationships between tables and row-level security constraints
• Dependencies between JAR objects
• Relationships between foreign server objects and table operators
70
Teradata Database-to-Teradata Aster
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Dictionary Tables
Row Value
Row
Description
RelationshipCode
The value KO indicates the relationship between the foreign
server and the table operator.
DBC.ServerInfo
This Teradata QueryGrid connector Data Dictionary table stores the name value pairs of the
server object that are used by the table operators to connect to the foreign server if the name
value pair of the USING clause is specified in the CREATE/ALTER FOREIGN SERVER
statement.
Row Values
DBC.ServerInfo Field
Description
DatabaseID
The database ID that contains the server object.
NameInfo
The name attribute specified in the name value pair of
the USING clause in the CREATE or ALTER
FOREIGN SERVER statement.
NameInfoType
Possible values include:
• G indicates the server attribute name value pair
defined in the USING clause of the CREATE or
ALTER FOREIGN SERVER statement.
• I indicates the IMPORT table operator name value
pair defined in the USING clause of the CREATE
or ALTER FOREIGN SERVER statement.
• E indicates the EXPORT table operator name value
pair defined in the USING clause of the CREATE
or ALTER FOREIGN SERVER statement.
ServerID
The ID of the server object.
ValueInfo
The value attribute specified in the name value pair of
the USING clause in the CREATE or ALTER
FOREIGN SERVER statement.
DBC.ServerTblOpInfo
This Teradata QueryGrid connector Data Dictionary table stores information about the table
operator associated with the foreign server.
This table also includes the database and table operator names to avoid issues with the object
ID changing during an archive or restore operation.
Teradata Database-to-Teradata Aster
71
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Dictionary Tables
Row Values
DBC.ServerTblOpInfo Field
Description
DatabaseId
The database ID that contains the foreign server
object.
ServerID
The ID of the foreign server.
TblOpDatabaseName
The database name in which the table operator is
defined.
TblopName
The name of the table operator associated with the
foreign server.
TblOpType
Possible values include:
• I indicates the IMPORT table operator name value
pair.
• E indicates the EXPORT table operator name value
pair.
• 'UNKNOWN' indicates an unknown name value
pair.
Note: This column may return more than one operator
type.
DBC.DBQLStepTbl
This DBQL table stores information about each processing step used to satisfy the query. For
a Teradata QueryGrid connector query, this includes the size of the data transferred between
Teradata and a foreign server. One row is logged for each step.
This Data Dictionary table is only populated if you specify the WITH STEPINFO option in
the BEGIN or REPLACE QUERY LOGGING statement. When the query completes, the
system logs one row for each query step, including parallel steps.
Row Value
Row
Description
ServerByteCount
The number of row bytes read from or sent to a foreign server
object.
This column is NULL if the step does not load or send data to or
from a foreign server.
Related Topics
72
For more information ...
See ...
For more information about the DBQL feature,
how to enable DBQL logging, the
DBC.DBQStepTbl table and fields
Database Administration
B035-1093
Teradata Database-to-Teradata Aster
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Dictionary Tables
For more information ...
See ...
For more information about the BEGIN/
REPLACE QUERY LOGGING statement
SQL Data Definition Language - Syntax and
Examples
B035-1144
DBC.TVM Table
This Data Dictionary table stores one row for each of the following objects on the system:
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Column
Database
External stored procedure
Hash index
JAR
Join index
Macro
Stored procedure
Table
Trigger
User-defined function
User-defined method
User-defined type
View
For Teradata QueryGrid connector queries, the DBC.TVM table stores one row for each
foreign server object on the Teradata Database system if one of the following options is
specified:
• The TRUSTED security type of the CREATE or REPLACE AUTHORIZATION
statement.
• The optional comment string of the SQL COMMENT statement.
The DBC.TVM table is not archived during archive and restore operations.
Row Values
Row
Description
AuthIdUsed
The authorization ID of the foreign server object.
This row returns NULL if the foreign server object is not authorized.
AuthName
The name of the authorization defined for the foreign server object.
This row returns NULL if the foreign server object is not authorized.
AuthorizationSubType
Teradata Database-to-Teradata Aster
Whether the specified authorization is the default authorization.
Possible values include:
• I indicates the specified INVOKER TRUSTED authorization.
• D indicates DEFINER TRUSTED authorization.
• F indicates DEFINER DEFAULT TRUSTED authorization.
73
Chapter 5 Data Dictionary Tables and Views for Teradata QueryGrid: Teradata Database-to-Teradata Aster Database
Teradata-to-Aster Connector Dictionary Tables
Row
Description
•
NULL indicates the foreign server object is not authorized.
AuthorizationType
The type of authorization of the foreign server object. Possible values
include:
• T indicates that the TRUSTED security type of the CREATE or
REPLACE AUTHORIZATION statement is specified.
• NULL indicates the foreign server object is not authorized
CommentString
Text or comment supplied by the user on the column, database, table,
view, macro, user-defined function, user-defined types, user-defined
methods, stored procedure, role, profile, user, or foreign server.
TableKind
If you are using a foreign server object, this row returns K.
Note: K is supported on the Teradata QueryGrid connectors only.
For more information on TableKind values, see Data Dictionary,
B035-1092.
74
Teradata Database-to-Teradata Aster
APPENDIX A
Notation Conventions
About Notation Conventions
This appendix describes the notation conventions used in this book.
Convention
Description
Syntax Diagrams
Describes SQL syntax form, including options.
Square braces in the text
Represent options. The indicated parentheses are required when you
specify options.
For example:
DECIMAL [(n[,m])] means the decimal data type can be defined
optionally:
• without specifying the precision value n or scale value m
• specifying precision (n) only
• specifying both values (n,m)
You cannot specify scale without first defining precision.
• CHARACTER [(n)] means that use of (n) is optional.
The values for n and m are integers in all cases.
Syntax Diagram Conventions
Notation Conventions
Item
Definition and Comments
Letter
An uppercase or lowercase alphabetic character ranging from A through Z.
Number
A digit ranging from 0 through 9.
Do not use commas when typing a number with more than 3 digits.
Word
Teradata Database-to-Teradata Aster
Keywords and variables.
• UPPERCASE LETTERS represent a keyword.
Syntax diagrams show all keywords in uppercase, unless operating system
restrictions require them to be in lowercase.
75
Appendix A Notation Conventions
Syntax Diagram Conventions
Item
Definition and Comments
•
•
lowercase letters represent a keyword that you must type in lowercase, such
as a Linux command.
Mixed Case letters represent exceptions to uppercase and lowercase rules.
The exceptions are noted in the syntax explanation.
lowercase italic letters represent a variable such as a column or table name.
•
Substitute the variable with a proper value.
lowercase bold letters represent an excerpt from the diagram.
•
The excerpt is defined immediately following the diagram that contains it.
UNDERLINED LETTERS represent the default value.
•
This applies to both uppercase and lowercase words.
Spaces
Use one space between items such as keywords or variables.
Punctuation
Type all punctuation exactly as it appears in the diagram.
Paths
The main path along the syntax diagram begins at the left with a keyword, and proceeds, left
to right, to the vertical bar, which marks the end of the diagram. Paths that do not have an
arrow or a vertical bar only show portions of the syntax.
The only part of a path that reads from right to left is a loop.
Continuation Links
Paths that are too long for one line use continuation links. Continuation links are circled
letters indicating the beginning and end of a link:
A
A
When you see a circled letter in a syntax diagram, go to the corresponding circled letter and
continue reading.
Required Entries
Required entries appear on the main path:
SHOW
SHOW
CONTROLS
VERSIONS
If you can choose from more than one entry, the choices appear vertically, in a stack. The first
entry appears on the main path:
SHOW
CONTROLS
VERSIONS
76
Teradata Database-to-Teradata Aster
Appendix A Notation Conventions
Syntax Diagram Conventions
Optional Entries
You may choose to include or disregard optional entries. Optional entries appear below the
main path:
SHOW
CONTROLS
If you can optionally choose from more than one entry, all the choices appear below the
main path:
READ
SHARE
ACCESS
Some commands and statements treat one of the optional choices as a default value. This
value is UNDERLINED. It is presumed to be selected if you type the command or statement
without specifying one of the options.
Strings
String literals appear in apostrophes:
'msgtext '
Abbreviations
If a keyword or a reserved word has a valid abbreviation, the unabbreviated form always
appears on the main path. The shortest valid abbreviation appears beneath.
SHOW
CONTROLS
CONTROL
In the above syntax, the following formats are valid:
SHOW CONTROLS
SHOW CONTROL
Loops
A loop is an entry or a group of entries that you can repeat one or more times. Syntax
diagrams show loops as a return path above the main path, over the item or items that you
can repeat:
,
,
(
3
4
cname
)
Read loops from right to left.
The following conventions apply to loops:
Item
Description
Example
maximum number of entries
allowed
The number appears in a
circle on the return path.
In the example, you may type
cname a maximum of four
times.
Teradata Database-to-Teradata Aster
77
Appendix A Notation Conventions
Syntax Diagram Conventions
Item
Description
Example
minimum number of entries
allowed
The number appears in a
square on the return path.
In the example, you must type
at least three groups of column
names.
separator character required
between entries
The character appears on the
return path.
In the example, the separator
character is a comma.
If the diagram does not show
a separator character, use one
blank space.
delimiter character required
around entries
The beginning and end
In the example, the delimiter
characters appear outside the characters are the left and right
return path.
parentheses.
Generally, a space is not
needed between delimiter
characters and entries.
Excerpts
Sometimes a piece of a syntax phrase is too large to fit into the diagram. Such a phrase is
indicated by a break in the path, marked by (|) terminators on each side of the break. The
name for the excerpted piece appears between the terminators in boldface type.
The boldface excerpt name and the excerpted phrase appears immediately after the main
diagram. The excerpted phrase starts and ends with a plain horizontal line:
LOCKING
excerpt
HAVING
con
excerpt
where_cond
,
cname
,
col_pos
Multiple Legitimate Phrases
In a syntax diagram, it is possible for any number of phrases to be legitimate:
dbname
DATABASE
tname
TABLE
vname
VIEW
In this example, any of the following phrases are legitimate:
dbname
78
Teradata Database-to-Teradata Aster
Appendix A Notation Conventions
Character Shorthand Notation Used in This Book
DATABASE dbname
tname
TABLE tname
vname
VIEW vname
Sample Syntax Diagram
,
CREATE VIEW
viewname
AS
A
cname
CV
LOCKING
LOCK
ACCESS
dbname
A
DATABASE
FOR
SHARE
IN
tname
READ
TABLE
WRITE
EXCLUSIVE
vname
VIEW
EXCL
,
B
SEL
B
MODE
expr
,
FROM
qual_cond
tname
C
.aname
C
HAVING cond
;
qual_cond
,
WHERE cond
GROUP BY
cname
,
col_pos
Character Shorthand Notation Used in This Book
This book uses the Unicode naming convention for characters. For example, the lowercase
character ‘a’ is more formally specified as either LATIN CAPITAL LETTER A or U+0041.
The U+xxxx notation refers to a particular code point in the Unicode standard, where xxxx
stands for the hexadecimal representation of the 16-bit value defined in the standard.
In parts of the book, it is convenient to use a symbol to represent a special character, or a
particular class of characters. This is particularly true in discussion of the following Japanese
character encodings:
• KanjiEBCDIC
• KanjiEUC
• KanjiShift-JIS
These encodings are further defined in International Character Set Support.
Teradata Database-to-Teradata Aster
79
Appendix A Notation Conventions
Character Shorthand Notation Used in This Book
Character Symbols
The symbols, along with character sets with which they are used, are defined in the following
table.
Symbol
Encoding
Meaning
a-z
A-Z
0-9
Any
Any single byte Latin letter or digit.
a-z
A-Z
0-9
Any
Any fullwidth Latin letter or digit.
<
KanjiEBCDIC
Shift Out [SO] (0x0E).
Indicates transition from single to multibyte character in
KanjiEBCDIC.
>
KanjiEBCDIC
Shift In [SI] (0x0F).
Indicates transition from multibyte to single byte KanjiEBCDIC.
T
Any
Any multibyte character.
The encoding depends on the current character set.
For KanjiEUC, code set 3 characters are always preceded by ss3.
I
Any
Any single byte Hankaku Katakana character.
In KanjiEUC, it must be preceded by ss2, forming an individual
multibyte character.
Δ
Any
Represents the graphic pad character.
Δ
Any
Represents a single or multibyte pad character, depending on
context.
ss2
KanjiEUC
Represents the EUC code set 2 introducer (0x8E).
ss3
KanjiEUC
Represents the EUC code set 3 introducer (0x8F).
For example, string “TEST”, where each letter is intended to be a fullwidth character, is
written as TEST. Occasionally, when encoding is important, hexadecimal representation is
used.
For example, the following mixed single byte/multibyte character data in KanjiEBCDIC
character set
LMN<TEST>QRS
is represented as:
D3 D4 D5 0E 42E3 42C5 42E2 42E3 0F D8 D9 E2
Pad Characters
The following table lists the pad characters for the various character data types.
80
Teradata Database-to-Teradata Aster
Appendix A Notation Conventions
Character Shorthand Notation Used in This Book
Server Character Set
Pad Character Name
Pad Character Value
LATIN
SPACE
0x20
UNICODE
SPACE
U+0020
GRAPHIC
IDEOGRAPHIC SPACE
U+3000
KANJISJIS
ASCII SPACE
0x20
KANJI1
ASCII SPACE
0x20
Teradata Database-to-Teradata Aster
81
Appendix A Notation Conventions
Character Shorthand Notation Used in This Book
82
Teradata Database-to-Teradata Aster