Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
41
Добавлен:
18.03.2015
Размер:
209.69 Кб
Скачать

Firebird 2 Quick Start

The DISTINCT keyword comes to the rescue!

Firebird 2 implements a new use of the DISTINCT keyword allowing you to perform (in)equality tests that take NULL into account. The semantics are as follows:

Two expressions are DISTINCT if they have different values or if one is NULL and the other isn't;

They are NOT DISTINCT if they have the same value or if both are NULL.

Notice that if neither operand is NULL, DISTINCT works exactly like the “<>” operator, and NOT DISTINCT like the “=” operator.

DISTINCT and NOT DISTINCT always return true or false, never NULL.

Using DISTINCT, you can rewrite the first PSQL example as follows:

if (a is not distinct from b) then MyVariable = 'Equal';

else

MyVariable = 'Not equal';

And the second as:

if (a is distinct from b) then MyVariable = 'Not equal';

else

MyVariable = 'Equal';

These versions will give you the results that a normal human being (untouched by SQL standards) would expect, whether there are NULLs involved or not.

More about NULLs

A lot more information about NULL behaviour can be found in the Firebird Null Guide, at these locations:

http://www.firebirdsql.org/manual/nullguide.html (HTML)

http://www.firebirdsql.org/pdfmanual/Firebird-Null-Guide.pdf (PDF)

An updated and greatly extended version of the Null Guide is available since January 2007.

Preventing data loss

Backup

Firebird comes with two utilities for backing up and restoring your databases: gbak and nbackup. Both can be found in the bin subdirectory of your Firebird installation. Firebird databases can be backed up whilst users are connected to the system and going about their normal work. The backup will be taken from a snapshot of the database at the time the backup began.

Regular backups and occasional restores should be a scheduled part of your database management activity.

26

Соседние файлы в папке doc