CREATE/REPLACE CAST Examples | Teradata Vantage - CREATE CAST and REPLACE CAST Examples - Teradata Vantage - Analytics Database

SQL Data Definition Language Syntax and Examples

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-11-06
dita:mapPath
jco1628111346878.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
mdr1472255012272
lifecycle
latest
Product Category
Teradata Vantage™

Example: Casting Source Data as VARCHAR

The following CREATE CAST request creates a cast operation that converts the source data type circle to the target data type VARCHAR(32) using the method having the specific method name circleToVarchar.

     CREATE CAST (circle AS VARCHAR(32))
     WITH SPECIFIC METHOD SYSUDTLIB.circleToVarchar

Example: Casting Source Data using a UDF

The following CREATE CAST request creates a cast operation that converts the source data type VARCHAR(32) to the target data type circle using the UDF having the specific function name VarcharTocircle.

     CREATE CAST (VARCHAR(32) AS circle)
     WITH SPECIFIC FUNCTION SYSUDTLIB.VarcharTocircle

Example: Casting Source Data as VARCHAR with an Assignment Operation

The following CREATE CAST request creates a cast operation that converts the source data type euro to the target data type VARCHAR(20) using the method euroString.

The casting routine is defined so it is implicitly invoked on an assignment operation assuming the necessary conditions are met for the assignment.

     CREATE CAST (euro AS VARCHAR(20))
     WITH METHOD SYSUDTLIB.euroString( ) FOR euro
     AS ASSIGNMENT