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

Teradata RDBMS forUNIX SQL Reference - NCR

NCR Teradata RDBMS forUNIX SQL Reference - NCR, 1997. - 913 p.
Download (direct link): teradataforunix1997.pdf
Previous << 1 .. 10 11 12 13 14 15 < 16 > 17 18 19 20 21 22 .. 241 >> Next

• When an update supplies the value NULL and a NULL is allowed, any existing data is removed from the field.

• If the result of an UPDATE will violate uniqueness constraints or create a duplicate row in a table which does not allow duplicate rows, an error message is returned.

The DELETE statement allows you to remove an entire row or rows

from a table. A WHERE clause qualifies the rows that are deleted.

Teradata RDBMS for UNIX SQL Reference

Data Handling Fundamentals

Default Database

Default Database

While in a Teradata session, you may repeatedly query, define, and manipulate data from a single database. To avoid keying the name of the database each time you enter a statement, establish a default database by specifying the name in a DATABASE statement. Once defined, the default database remains in effect until the end of a session or until it is replaced by a subsequent DATABASE statement.

Once you establish a default database, SQL automatically supplies the database name every time you enter a statement.

For example, after entering:

DATABASE personnel ;

you can enter a SELECT statement as follows:

SELECT deptno (TITLE 'Org'), name FROM employee ;

which would have the same results as:

SELECT deptno (TITLE 'Org'), name FROM personnel.employee;

To establish a default database, you must have some privilege on a database, macro, table, user, or view in that database.

You can define a default database for subsequent sessions. Enter a MODIFY USER statement with a DEFAULT database clause that specifies the name of a database that will be invoked each time you log on. For example, the following statement automatically establishes Personnel as Marks’ default database at the next logon:


DEFAULT DATABASE = personnel ;

The statement examples in this document assume that you have established Personnel as your default database. To obtain information from a table in another database, specify that database name, a period, and the table name.

For further information about using a default database refer to Teradata RDBMS for UNIX Database Design & Administration, Chapter 8, under “Object Ownership.”


Teradata RDBMS for UNIX SQL Reference
Data Handling Fundamentals



Contents of a Macro


A frequently used SQL statement or series of statements, can be set up in a macro and defined using CREATE MACRO. See “CREATE MACRO” in Chapter 8, “Teradata SQL Syntax Guide.”.

The statements in the macro are executed using the EXECUTE statement. See “EXECUTE” in Chapter 8, “Teradata SQL Syntax Guide.”

A macro can include an EXECUTE statement that executes another macro.

You can create a macro for your own use, or grant the privilege of executing it to others. For example, your macro may enable a user in another department to perform operations on the data in the Teradata RDBMS. In executing the macro, the user need not be aware of the database being accessed, the tables affected, or even the results.

Note: Although a multi-statement operation may be entered interactively, using an explicit transaction (either BT/ET or COMMIT) it is preferable to define such an operation as a macro, because an explicit transaction will cause locks placed on objects by statements in the transaction to be held until the statement sequence is completed with an END TRANSACTION or COMMIT. If you were to enter such a sequence interactively from BTEQ, items in the database could remain locked to others while you keyed and entered each statement.

A macro is deleted by using the DROP MACRO statement.

A macro can contain a data definition statement (for example, CREATE, ALTER, MODIFY) if it is the only SQL statement in that macro. Such a data definition statement is not resolved until the macro is executed, at which time unqualified database object references are fully resolved using the default database of the user submitting the EXECUTE statement. It is, therefore, recommended that object references in a macro data definition statement be fully qualified (e.g., databasename.tablename) in the macro body.

A macro may contain parameters that are filled each time the macro is executed. It also may include a USING modifier, which allows the parameters to be filled with data from an external source such as a disk file. The colon character is used to prefix references to a parameter name in the macro.

Teradata RDBMS for UNIX SQL Reference

Data Handling Fundamentals


Executing a Macro

In general, the statements that make up a macro are written into a file on a text processing system, and then are transferred via a utility such as BTEQ.

Changes and corrections are made via the text processing system and the REPLACE MACRO statement. A macro also may be deleted and a replacement created. If you are unfamiliar with any part of this process, be sure to coordinate with your installation’s system or database administrator.
Previous << 1 .. 10 11 12 13 14 15 < 16 > 17 18 19 20 21 22 .. 241 >> Next