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 .. 84 85 86 87 88 89 < 90 > 91 92 93 94 95 96 .. 241 >> Next


If a SELECT statement that contains a built-in value references a table name, then the result of the query contains one row for every row of the table that satisfies the search condition.

Teradata RDBMS for UNIX SQL Reference

6-97
SQL Expressions DATE

DATE

Introduction
Caution:
Form6

Example

The DATE built-in value supplies the current date. It is of data type DATE, length 4, and is nullable.

This is not the ANSI form of DATE, and when used it will be flagged if the SQL flagger is enabled.

The value of DATE as stored internally allows for dates from 000101-01 to 3500-12-31. To avoid problems concerning years from 200001-01 on, use the format ‘YYYY-MM-DD’.

The default format of the DATE built-in value is YY/MM/DD.

The following example selects today’s date:

SELECT DATE;

The system returns:

Date

96/03/30

Use the FORMAT phrase to change the presentation:

SELECT date (FORMAT 'mm-dd-yy') ;

Date

03-30-96

Another form gives:

SELECT date (FORMAT 'mmmbdd,byyyy') ;

Date Mar 30, 1996

Examples of date formats are listed as follows:

Format

'yyyy-mm-dd'

'yy/mm/dd'

'mm/dd/yy'

'mmbddbyy'

'mmmbdd,byyyy'

'mmm.dd.yy'

'yy--mm--dd'

'dddyy'

'dd.mm.yyyy'

Result

1996-11-30 96/03/30 03/30/96 03 30 96 Mar 30, 1996 Mar.30.96 96--03--30 08996

30.03.1996

This is the ANSI format

6-98

Teradata RDBMS for UNIX SQL Reference
SQL Expressions TIME

TIME

Introduction

The TIME built-in value provides the current time.

Time is based on a 24-hour day, and is stored as HHMMSS.CC (hours, minutes, seconds, and hundredths of a second).

Form

The format of the TIME built-in value is defined as 99:99:99; the type is FLOAT, and the length is 8.

Example

For example:

SELECT TIME (FORMAT '99:99:99.99');

The hundredths of a second are not displayed by the default format; they can be displayed by overriding the format.

This is not the ANSI form of time. It will be flagged if the SQL flagger is enabled.

The following example inserts a row in a hypothetical table (in which the column ’InsertTime’ is data type FLOAT) and records the time that the row was inserted:

INSERT INTO HypoTable (ColumnA, ColumnB, InsertTime)

VALUES ('Abcde', 12345, TIME);

Teradata RDBMS for UNIX SQL Reference

6-99
SQL Expressions USER

Introduction

Example

USER

The USER built-in value provides the user name of the current user.

Internal representation of the format of the USER value is as follows:

VARCHAR(3 0) NOT NULL,

You can identify the current user with the following statement:

SELECT user ;

The system responds with something like:

User

SQL01

The following example selects the job title for the current user.

SELECT JobTitle FROM Employee WHERE Name = USER;

6-100

Teradata RDBMS for UNIX SQL Reference
SQL Expressions NULL

NULL

The NULL built-in value has no data type. NULL can be assigned to a field to indicate that the value is not known or not applicable to that field.

If a row is inserted into a table without specifying values for some of the columns, the columns will be set to NULL, assuming there is no default value or a column has not been defined as NOT NULL.

Teradata RDBMS for UNIX SQL Reference

6-101
SQL Expressions

Indicator Variables

Indicator Variables

In indicator mode, the Teradata RDBMS returns data in client system internal format.

Immediately preceding the first response row is a DataInfo parcel containing information on the total number of columns returned, the data type, and length of each column. Each response row begins with indicator variables corresponding to each data item in that row.

The indicator variables are:

0 Indicates that the value in the corresponding field is not NULL or is non-nullable.

1 Indicates that the value in the corresponding field is NULL.

Indicator variables are processed by the Teradata RDBMS as follows:

• One indicator variable corresponds to each data item (field) of a response row.

• Each indicator variable occupies one bit of space.

• If there are n data fields, the first (n + 7)/8 bytes of a response row contain the indicator variables for the data in that row.

For example, if a response row contains 19 data items, then (19 + 7)/8 = 3 bytes contain the indicator variables for that row.)

• Indicator variables are held in the minimum number of eight-bit bytes required to store them; unused bits are zeroed.

6-102

Teradata RDBMS for UNIX SQL Reference
Queries: The SELECT Statement

Chapter 7

Queries: The SELECT Statement

TeradataR DBMS for UNIX SQL Reference
Queries: The SELECT Statement

Teradata RDBMS for UNIX SQL Reference
Queries: The SELECT Statement

About This Chapter

About This Chapter

SQL queries are performed using the SELECT statement.

The form, usage, and examples of the SELECT statement are described in this chapter, along with the FROM list, and the various SELECT statement clauses.
Previous << 1 .. 84 85 86 87 88 89 < 90 > 91 92 93 94 95 96 .. 241 >> Next