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 .. 110 111 112 113 114 115 < 116 > 117 118 119 120 121 122 .. 241 >> Next


Constraint name unique_1 must not be an existing name in table_1.

Example 13 8

ALTER TABLE table_1 ADD CONSTRAINT unique_1 UNIQUE (field_1, field_2)

Constraint name reference_1 must not be an existing name in table_1.

Example 14 8

ALTER TABLE table_1 ADD CONSTRAINT reference_1 FOREIGN KEY (field 1) REFERENCES table 2

Constraint name check_1 must exist in table_1.

Example 15 8

ALTER TABLE table 1 DROP CONSTRAINT check 1

Constraint name check_1 must exist in table_1 as a CHECK constraint.

ALTER TABLE table_1 DROP CONSTRAINT check_1 CHECK

Constraint name unique_1 must exist in table_1.

Example 17

ALTER TABLE table_1 DROP CONSTRAINT unique_1

Constraint name reference_1 must exist in table_1.

Example 18 8

ALTER TABLE table 1 DROP CONSTRAINT reference 1

Example 16

8-26

Teradata RDBMS for UNIX SQL Reference
Teradata SQL Syntax Guide

ALTER TABLE

Example 19

Replace the current definition for CHECK constraint check_1 with the new definition.

Constraint name check_1 must be an existing CHECK constraint.

ALTER TABLE table_1 MODIFY CONSTRAINT check_1 CHECK (field 2 > 0)

Adding/Dropping Unnamed Constraints

Example 20

The following set of examples deals with adding or dropping unnamed constraints.

The following statement adds the unnamed check constraint to ensure that column field2 is always greater than 100.

ALTER TABLE table 1 ADD CHECK (field2 > 100)

Example 21

This example is valid only if there is not an existing unnamed column level CHECK for field_1 in table_1.

ALTER TABLE table_1 ADD field_1 CHECK (field 1 > 0)

Example 22

The following statement adds an unnamed uniqueness constraint to columns field_3 and field_4.

ALTER TABLE table 1 ADD UNIQUE (field 3, field 4)

Example 23

The following statement a foreign key designation for column field_2 in table_1.

ALTER TABLE table_1 ADD FOREIGN KEY (field_2)

REFERENCES table_3

Example 24

This example drops all unnamed table level CHECK constraints.

ALTER TABLE table 1 DROP CHECK

Example 25

This example drops the unnamed column level CHECK constraint from column field 1 in table 1.

ALTER TABLE table_1 DROP field_1 CHECK

Example 26

This example drops the foreign key designation for column field_2 in table table_3.

ALTER TABLE table_1 DROP FOREIGN KEY (field_2) REFERENCES table_3

Teradata RDBMS for UNIX SQL Reference

8-27
Teradata SQL Syntax Guide

ALTER TABLE

Example 27

Field field_1 is an existing, already constrained field in table_1.

ALTER TABLE table_1 MODIFY field_1 CHECK (field 1 IS NOT NULL)

Example 28: Non-Valid Use of ALTER TABLE: Constraints

The following statement is not valid because you can add or drop only one constraint per ALTER TABLE statement.

ALTER TABLE table_1

DROP CONSTRAINT check_1, ADD CONSTRAINT check_2 CHECK (field 2 > 0)

The system returns the message:

Only a check specification is allowed for the modification.

Example 29: Non-Valid Use of ALTER TABLE: Named Constraints

By definition, the constraint named dup_constr_name already exists in table_1. For this reason, you cannot add it to the table.

ALTER TABLE table_1

ADD CONSTRAINT dup_constr_name FOREIGN KEY (field_3) REFERENCES table 2

The system returns the message:

Constraint with the same name 'dup_constru_name' already exists in table.

By definition, the constraint named no_such_constr does not exist in table_1. For this reason, you cannot modify or drop it.

Example 30: Non-Valid Use of ALTER TABLE: Named Constraints

The following statement is not valid.

ALTER TABLE table_1

MODIFY CONSTRAINT no_such_constr CHECK (field 1 > 0)

Example 31: Non-Valid Use of ALTER TABLE: Named Constraints

The following statement is not valid.

ALTER TABLE table_1

DROP CONSTRAINT no_such_constr

The system returns the message:

The specified constraint name does not exist in table.

8-28

Teradata RDBMS for UNIX SQL Reference
Teradata SQL Syntax Guide

BEGIN/END LOGGING

BEGIN/END LOGGING

The BEGIN LOGGING and END LOGGING statements start and stop the auditing of SQL requests that attempt to access data. Each time a user named in a BEGIN LOGGING statement attempts to execute a specified action against a specified object, an entry is logged in the system table DBC.AccLogTbl. Possible entry data includes the type of access, the text of the request, the frequency of access, the action requested, the name of the requesting user, and the referenced objects.

Logging can be ended on any action, user, or object for which logging is currently active.

A logging entry does not indicate that a statement was executed; rather, it indicates that the system checked the privileges necessary to execute the statement.

These statements may be executed only if the DIPACC DBCSQL script, which is provided on the software release tape, has been run to create the special security macro DBC.AccLogRule, and the system has been reset to initialize the logging software. Otherwise, access logging will not be allowed on the Teradata RDBMS.
Previous << 1 .. 110 111 112 113 114 115 < 116 > 117 118 119 120 121 122 .. 241 >> Next