16.20 - CREATE storage_format SCHEMA - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantage™ SQL Data Definition Language Syntax and Examples

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Content Type
Programming Reference
Publication ID
B035-1144-162K
Language
English (United States)
Last Update
2019-05-24

Purpose

Creates a schema for a specific storage format of the DATASET type.

For information on the DATASET data type, see Teradata Vantage™ DATASET Data Type, B035-1198.

Required Privileges

You must have the CREATE DATASET SCHEMA privilege on the target database.

Syntax



Syntax Elements

storage_format
Storage format of the DATASET type to use in creating the schema.
SYSUDTLIB
Name of the database containing the schema. Schemas that you create are registered in the SYSUDTLIB database.
schema_name
Name of the schema. Schema names must be unique across the entire system.
schema
You must specify the schema as a constant, that is, literal value. The literal can contain the schema in its text format or in a byte format which contains the UTF-8 encoded characters that compose the schema. Schemas are stored as a Teradata VARBYTE which contains the UTF-8 encoded characters that compose the schema, to a maximum of 63,000 bytes.

Examples

This example creates a schema in the Avro storage format of the DATASET type:
CREATE Avro SCHEMA chemDatasetSchema AS
'{
	"namespace": "example.avro",
 	"type": "record",
 	"name": "User",
 	"fields": [
     		{"name": "name", "type": "string"},
    		{"name": "favorite_number",  "type": ["int", "null"]},
     		{"name": "favorite_color", "type": ["string", "null"]}
 	 ]
	}';
This example creates the same schema using a byte literal which contains the UTF-8 encoded characters of the schema:
CREATE Avro SCHEMA chemDatasetSchema AS
'7B226E616D657370616365223A226578616D706C652E6176726F222C2274797065223A227265636F7264222C226E616D65223A2255736572222C226669656C6473223A5B7B226E616D65223A226E616D65222C2274797065223A22737472696E67227D2C7B226E616D65223A226661766F726974655F6E756D626572222C2274797065223A5B22696E74222C226E756C6C225D7D2C7B226E616D65223A226661766F726974655F636F6C6F72222C2274797065223A5B22737472696E67222C226E756C6C225D7D5D7D'xb;

Usage Notes

The schemas you specify are converted to UTF-8 before insertion into the DBC.DatasetSchemaInfo table.