Online Documentation for SQL Manager for InterBase/Firebird

Table Constraints


Constraints let you define the way the server automatically enforces the integrity of a database. Constraints define rules regarding the values allowed in columns and are the standard mechanism for enforcing integrity.

 

A PRIMARY KEY constraint designates a column as the Primary key of a table. A composite primary key designates a combination of columns as the primary key.

 

Table primary keys are managed within the Constraints | Primary Key tab of Table Editor.

 

A FOREIGN KEY constraint (also called a referential integrity constraint) designates a column as the Foreign key and establishes a relationship between that foreign key and a specified Primary or Unique key called the referenced key. A composite Foreign key designates a combination of columns as the foreign key.

 

Table Foreign keys are managed within the Constraints | Foreign Keys tab of Table Editor.

 

A CHECK specifies an expression producing a Boolean result which new or updated rows must satisfy for an insert or update operation to succeed. Expressions evaluating to TRUE or UNKNOWN succeed. Should any row of an insert or update operation produce a FALSE result an error exception is raised and the insert or update does not alter the database. A check constraint specified as a column constraint should reference that column's value only, while an expression appearing in a table constraint may reference multiple columns.

 

Table checks are managed within the Constraints | Checks tab of Table Editor.

 

A UNIQUE constraint prevents insertion or updating of duplicate values into table columns.

 

Table unique keys are managed within the Constraints | Uniques tab of Table Editor.

 

Creating Primary Keys

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Primary Key tab there;
  • right-click the tab area and select the New Primary Key... context menu item, or press the Ins key;
  • define the primary key properties using the Constraints Editor dialog.

 

Editing Primary Keys

To edit an existing primary key:

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Primary Key tab there;
  • right-click the primary key and select the Edit Primary Key <PK_name> context menu item, or simply double-click the primary key;
  • edit the primary key properties using the Constraints Editor dialog.

To change the name of a primary key:

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Primary Key tab there;
  • right-click the primary key to rename and select the Rename Primary Key <PK_name>... item from the context menu;
  • edit the primary key name using the Rename Object... dialog.

 

Dropping Primary Keys

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Primary Key tab there;
  • right-click the primary key and select the Drop Primary Key <PK_name> context menu item, or press the Del key;
  • confirm dropping in the dialog window.

 

Creating Foreign Keys

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Foreign Keys tab there;
  • right-click the tab area and select the New Foreign Key... context menu item, or press the Ins key;
  • define the Foreign key properties using the Constraints Editor dialog.

 

Editing Foreign Keys

To edit an existing Foreign key:

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Foreign Keys tab there;
  • right-click the Foreign key and select the Edit Foreign Key <FK_name>... context menu item, or simply double-click the Foreign key;
  • edit the Foreign key properties using the Constraints Editor dialog.

To change the name of a Foreign key:

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Foreign Keys tab there;
  • right-click the Foreign key to rename and select the Rename Foreign Key <FK_name>... item from the context menu;
  • edit the Foreign key name using the Rename Object... dialog.

 

Dropping Foreign Keys

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Foreign Keys tab there;
  • right-click the Foreign key and select the Drop Foreign Key <FK_name> context menu item, or press the Del key;
  • confirm dropping in the dialog window.

 

Creating Checks

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Checks tab there;
  • right-click the tab area and select the New Check... context menu item, or press the Ins key;
  • define the check properties using the Constraints Editor dialog.

 

Editing Checks

To edit an existing check:

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Checks tab there;
  • right-click the check and select the Edit Check <check_name>... context menu item, or simply double-click the check;
  • edit the check properties using the Constraints Editor dialog.

To change the name of a check:

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Checks tab there;
  • right-click the check to rename and select the Rename Check <check_name>... item from the context menu;
  • edit the check name using the Rename Object... dialog.

 

Dropping Checks

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Checks tab there;
  • right-click the check and select the Drop Check <check_name> context menu item, or press the Del key;
  • confirm dropping in the dialog window.

 

Creating Unique Keys

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Uniques tab there;
  • right-click the tab area and select the New Unique... context menu item, or press the Ins key;
  • edit the unique key properties using the Constraints Editor dialog.

 

Editing Unique Keys

To edit an existing unique key:

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Uniques tab there;
  • right-click the unique key and select the Edit Unique <unique_name>... context menu item, or simply double-click the unique key;
  • edit the unique key properties using the Constraints Editor dialog.

To change the name of a unique key:

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Uniques tab there;
  • right-click the unique key to rename and select the Rename Unique <unique_name>... item from the context menu;
  • edit the unique key name using the Rename Object... dialog.

 

Dropping Unique Keys

  • open the table in Table Editor;
  • proceed to the Constraints tab, and then to the Uniques tab there;
  • right-click the unique key and select the Drop Unique <unique_name> context menu item, or press the Del key;
  • confirm dropping in the dialog window.