Create Database Objects with BTEQ Scripts | VantageCloud Lake - Using BTEQ Scripts to Create Database Objects - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905
Basic Teradata Query Utility (BTEQ) is a general-purpose, command-based application that allows users to do the following:
  • Perform administrative tasks, including creation of database objects such as databases, tables, and views, using SQL DCL, DDL, and DML requests.
  • Format reports for both print and screen output.

You can automate the creation of tables, views, and other database objects using BTEQ scripts.

The following example procedure uses a BTEQ script to create a sample table:
  1. Create a text file named Create_Emp_Table.sql with the following contents:
    .LOGON  tdpid/UserName,Password 
    CREATE SET TABLE Tables_Database.Employee,
    (Associate_Id INTEGER,
     Associate_Name CHAR(25),
     Salary DECIMAL(8,2),
     DOB DATE,
     Job_Title VARCHAR(25),
     Dept_No SMALLINT,
     Marital_Status CHAR,
     No_Of_Dependents BYTEINT)
    UNIQUE PRIMARY INDEX (Associate_Id);
    .quit
    tdpid
    The name by which the system is known to the network.
    UserName
    The name used to log on to Teradata, such as DBADMIN.
    Password
    The password associated with UserName.
  2. Create a batch file named Create_Emp.bat with the following contents:
    bteq < Create_Emp_Table.sql > Create_Emp_Table.log 2>&1

    Example:

    2>&1

    This example redirects the error messages to Create_Emp_Table.log to be printed with the output messages.

  3. Place Create_Emp.bat and Create_Emp_Table.sql in the same folder.
  4. Run Create_Emp.bat to create the Employee table in the database, Tables_Database.

Create_Emp.bat invokes BTEQ using Create_Emp_Table.sql as the input file. BTEQ runs the commands and statements in the Create_Emp_Table.sql file and writes its output and any errors to the Create_Emp_Table.log file.

For information about starting and exiting BTEQ, see Basic Teradata® Query Reference, B035-2414.

For information about running batch jobs to submit BTEQ commands and Teradata SQL, see Basic Teradata® Query Reference, B035-2414.