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 .. 7 8 9 10 11 12 < 13 > 14 15 16 17 18 19 .. 241 >> Next


ORDER BY deptno, name ;

the statement keyword is “SELECT”. The select list for this statement is made up of the names:

• Deptno, name, and salary (the column names)

• Personnel (the database name)

• Employee (the table name)

The optional clause

WHERE deptno IN(100, 500)

is introduced by the keyword WHERE.

The optional clause

ORDER BY deptno, name

is introduced by the keyword ORDER BY.

SQL statements are punctuated using:

• Periods to separate database names from table names, and table names from a particular column name (for example, personnel.employee.deptno).

• Commas to separate and distinguish column names in the select list, or column names or parameters in an optional clause.

• Apostrophes to delimit the boundaries of character string constants.

• Parentheses to group expressions or define the limits of a phrase.

• Semicolon to separate statements in multi-statement requests, and terminates requests submitted via certain utilities such as BTEQ.

• Quote marks to define the extent of nonstandard names.

• Colons to prefix reference parameters or client system variables.

To include an apostrophe or show possession in a title, double the apostrophes.

2-4

Teradata RDBMS for UNIX SQL Reference
Data Handling Fundamentals

Basic Data Manipulation

Case-Sensitivity

Refer to Chapter 5, “Character Data Types,”and Chapter 6, “SQL Expressions.”

The section on “Defining the Database” in the Teradata RDBMS for For Further lnfOTmation UNIX Database Design & Administration, describes how to create,

prototype, and restructure tables. Indexing, normalizing data, and designing the database for optimum performance, are also discussed there.

Teradata RDBMS for UNIX SQL Reference

2-5
Data Handling Fundamentals

Data Definition Statements

Data Definition Statements

Data definition statements enable you to:

• Create, drop, rename, and alter tables

• Create, drop, rename, and replace views and macros

• Create and drop indexes

• Create, drop, and modify users and databases

• Collect statistics on a column or index

• Grant and revoke privileges

• Give ownership of a database to another user

• Establish a default database

• Comment on database objects

• Set a different collation sequence for the session

A data definition statement may not be entered as part of a multi-statement request.

A data definition statement may be entered as:

• A single-statement request

• The solitary statement, or as the last statement, in an “explicit transaction” (one or more requests enclosed by user-supplied BEGIN TRANSACTION and END TRANSACTION statement in Teradata mode, or in ANSI mode, one or more requests ending with the COMMIT keyword).

• The solitary statement in a macro

Successful execution of a data definition statement automatically creates and updates entries in the Data Dictionary.

2-6

Teradata RDBMS for UNIX SQL Reference
Creating Tables

Data Handling Fundamentals

Data Definition Statements

Data definition statements include:

ALTER TABLE GIVE
COMMENT GRANT
COLLECT STATISTICS GRANT LOGON
CREATE MODIFY
DATABASE DATABASE
INDEX USER
MACRO RENAME
TABLE MACRO
USER TABLE
VIEW VIEW
DATABASE REPLACE
DELETE MACRO
DATABASE VIEW
USER REVOKE
DROP REVOKE LOGON
DATABASE SET SESSION COLLATION
INDEX TABLE
MACRO USER
STATISTICS VIEW

Tables are defined using the CREATE TABLE statement. The CREATE TABLE statement specifies a table name, one or more column names, and the attributes of each column.

The CREATE TABLE statement can also be used to define a primary index and one or more secondary indexes. You can define the primary index, and any secondary index as unique, depending on whether duplicate values are to be allowed in the indexed field or fields.

This statement can be used to specify the datablock size, percent freespace, and other attributes.

In either Teradata or ANSI mode, if a table is created

• not to allow duplicate rows, duplicate rows are not allowed. Such rows are silently ignored; no duplicate row error message is returned when they are encountered.

• to allow duplicate rows and has no UNIQUE indexes, duplicate rows are accepted.

For more information on duplicate row rules, refer to Chapter 8, “Teradata SQL Syntax Guide,”, “CREATE TABLE” and “INSERT” (INSERT...SELECT).

Teradata RDBMS for UNIX SQL Reference

2-7
Data Handling Fundamentals

Data Definition Statements

A primary index is required. If not defined, it is assigned automatically.

Secondary indexes can improve system performance; note, however, that creating a secondary index causes the Teradata RDBMS to build a separate internal subtable to contain the index data rows.

After the table is created and usage patterns have developed, additional secondary indexes can be defined with the CREATE INDEX statement.

See Chapter 8, “Teradata SQL Syntax Guide,” under the topics “CREATE TABLE” and “CREATE INDEX” for more information.
Previous << 1 .. 7 8 9 10 11 12 < 13 > 14 15 16 17 18 19 .. 241 >> Next