Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

Teradata RDBMS forUNIX SQL Reference - NCR

NCR Teradata RDBMS forUNIX SQL Reference - NCR, 1997. - 913 p.
Download (direct link): teradataforunix1997.pdf
Previous << 1 .. 31 32 33 34 35 36 < 37 > 38 39 40 41 42 43 .. 241 >> Next


To select Name as a fixed length field and Salary as an integer value:

Example5

SELECT CAST (Name AS CHAR(12)), CAST (Salary AS INTEGER) FROM Employee ;

A move to be fully ANSI compliant with regards to Case Sensitivity, ANSI Versus Teradata would have caused large regression problems. To facilitate the

Mode transition to ANSI SQL compatibility, two modes of operation,

concerning character comparison rules, Teradata mode and ANSI mode, are provided.

Installations may choose Teradata or ANSI mode as a system default, and sessions can individually be set to override the system default. Refer also to Chapter 9, “Advanced SQL.”, “Transaction Semantics: Operating in ANSI or Teradata Mode”.

5-4

Teradata RDBMS for UNIX SQL Reference
Data Definition

Data Type Attributes: ANSI Mode

Caution: Because some instances of comparison attributes occur with data

definitions, and others with text in queries (or text from dictionary tables scanned as queries are executed), use of the two modes can be rather involved and you should exercise caution when doing so.

You should use current Teradata RDBMS SQL syntax which is the most ANSI compliant for all newly written applications. The current release of Teradata SQL still supports old applications, written in prior versions of Teradata SQL.

Teradata RDBMS for UNIX SQL Reference

5-5
Data Definition

Data Types

Table 5-1

Data Type Declaration

Data Types

The data type phrase does the following:

• Specifies how data is presented to the user.

• Determines how data is stored on the Teradata RDBMS.

A data type phrase must be specified for each column when a table is created. No default data type is provided. A data type phrase can also be used to specify data conversions in expressions.

The data type is defined as being either numeric, character, or byte, by using the following data type phrases:

Data Type Aa NAb NEc
Numeric INTEGER SMALLINT BYTEINT DATEd REAL DOUBLE PRECISION FLOAT [n] DECIMAL [(n[,m])] NUMERIC [(n[,m])]
X
X
X X
X X
X
X
X
X
X
Character CHAR[(n)] VARCHAR(n) CHAR VARYING(n) LONG VARCHAR
X
X X
X X
X X
Bytee BYTE[(n)] VARBYTE(n)
X X
X X
Graphic GRAPHIC[(n)] VARGRAPHIC(n) LONG VARGRAPHIC
X X
X X
X X

a. A = Supported by ANSI SQL

5-6

Teradata RDBMS for UNIX SQL Reference
Data Definition

Data Types

Client System Data Types

Data Type Attributes

Table 5-2

Data Type Attributes

b. NA=Not Supported by ANSI SQL; Teradata SQL extension to ANSI SQL

c. NE= Not Entry Level ANSI SQL

d. DATE is (1) not Entry Level ANSI, and (2) not compatible with Intermediate or Full ANSI

e. All byte and graphic data types are flagged as non-ANSI SQL when the SQL flagger is enabled.

For further information on the different level of ANSI compliance in this release, refer to Appendix B, “Teradata SQL Versus ANSI SQL.”.

In addition to SQL data types, the Teradata RDBMS supports numeric, character, and byte data types as used on various supported client systems. Refer to the list of client related manuals in the Preface of this manual.

Table 5-2 lists the main Teradata data type attributes.

Data Type Attribute ANSI Teradata Extension to ANSI
NOT NULL X
UPPERCASE X
[NOT] CASESPECIFIC X
FORMAT quotestring X
TITLE quotestring X
NAMED name X
DEFAULT number X
DEFAULT USER X
DEFAULT DATE X
DEFAULT TIME X
DEFAULT NULL X
WITH DEFAULT X

Teradata RDBMS for UNIX SQL Reference

5-7
Data Definition

Data Types

Column Storage Attributes

Column Constraint Attributes

Column storage attributes are a Teradata RDBMS extension to ANSI SQL.

Column storage attributes for the Teradata RDBMS are:

• COMPRESS

• COMPRESS NUL

• COMPRESS quotestring

• COMPRESS constant

Constraint names are intermediate ANSI SQL, and will be flagged as non entry level ANSI SQL when the SQL flagger is enabled.

Column constraint attributes for the Teradata RDBMS are:

• CONSTRAINT

• CONSTRAINT UNIQUE

• CONSTRAINT PRIMARY KEY

• CONSTRAINT CHECK (boolean condition)

• CONSTRAINT REFERENCES tname col_name

5-8

Teradata RDBMS for UNIX SQL Reference
Data Definition

GRAPHIC Conversion

GRAPHIC Conversion

The GRAPHIC data type is not implicitly converted to any other Introduction 5 data type for the purposes of string or logical expression operations.

You cannot explicitly convert character data to graphic data. You

Character to Graphic can do this conversion implicitly by using the VARGRAPHIC

Conversion 5 function.

Under a KanjiEBCDIC character set, users can request the graphic equivalent of a character string. This type of conversion is done using the VARGRAPHIC string function, as shown in the following example:

SELECT VARGRAPHIC ('string_expr');

You can convert only graphic data explicitly, as shown in the

Other Conversions 5 following example:
Previous << 1 .. 31 32 33 34 35 36 < 37 > 38 39 40 41 42 43 .. 241 >> Next