Creating Domains

From InterBase
Jump to: navigation, search

A domain is a customized column definition that you use to create tables. When you create a table, you specify the characteristics of each column in the table. Often, across the tables in a database, there will be several columns that have the same characteristics. Rather than entering the same complex definition for each column, you can create a name for the collection of characteristics. This named set of column characteristics is called a domain. You can use this domain name in a column definition rather than typing out the full definition.

Note:If you are going to use domains in your column definitions, you must create the domains before you use them in table definitions.

Column characteristics include:

  • Datatype
  • Default value: a literal value, NULL, or the name of the current user (USER)
  • Nullability: NOT NULL prohibits NULL values in the column (columns are nullable by default)
  • CHECK constraints: checks that the value being entered meets specified criteria
  • Character set and optional collation order (output sort order for CHAR and VARCHAR columns)
  • When you specify a column, only a column name and datatype are required. All other characteristics are optional.

Image 025.jpg Connecting to the TUTORIAL database

  1. If you are not already connected to the Tutorial database, in IBConsole, log on as the TUTOR user to the Local InterBase server.
    • Select the Local Server in the left pane and then choose Server > Login to display the Server Login dialog.
    • The user name TUTOR is already in the first field. Enter the password “tutor4ib” and click Login.
  2. To connect to the TUTORIAL database highlight the Tutorial.gdb icon in the left pane and choose Database > Connect.

Advance To:

Entering Metadata Statements