To add a new column to a table, you define a new line in the Schema Editor that appears below the dashed line. When you create or alter the columns of a table, the Schema Editor issues prompts to assist you.
The Schema Editor progresses from left to right, completing one horizontal line of description for each column, with the name of the column at the left. Use the right arrow key to move the highlight to each field. To accept the default entry for each field, press RETURN or an arrow key.
As you finish one column, the cursor moves to the next line down, so that you can type another column name. Thus, the columns that make up the table are listed vertically.
You can change or bypass any field entry in a line before you move to the next line in either of the following ways:
After you move the cursor to another line, you must use the Modify option on the CREATE TABLE menu to change your entry, as Modifying Columns (Modify Option) describes.
The Add option on the CREATE TABLE (or ALTER TABLE) menu places the cursor on an empty line and displays the ADD COLUMN NAME prompt. Type the name of the column after the ADD COLUMN NAME prompt and press RETURN. You can assign any name, as long as you follow the identifier syntax guidelines described in the IBM Informix: Guide to SQL Syntax.
DB–Access enters the specified name under Column Name, as Figure 47 shows.
ADD COLUMN NAME >>
Enter column name. RETURN adds it. INTERRUPT returns to CREATE/ALTER menu.
---- Page 1 of 1 ---- mydata@mydbserv ---------- Press CTRL-W for Help ----
Column Name Type Length Index Nulls
customer_num
The ADD TYPE menu displays various data types, as Figure 48 shows.
ADD TYPE clients : Char Numeric Serial Date Money date-Time ... Permits any combination of letters, numbers, and punctuation. ---- Page 1 of 1 ----- mydata@mydbserv ---------- Press CTRL-W for Help ---- Column Name Type Length Index Nulls customer_num
To select the data type for the column, type the first capitalized letter of the data type, using either uppercase or lowercase letters or the SPACEBAR to highlight it and then press RETURN.
The CREATE TABLE menu provides options for built-in data types. To define a column with one of the extended data types, such as smart large objects, user-defined (opaque) data types, or a collection data type, use the SQL menu to enter and run a CREATE TABLE statement.
If you select one of the following data type categories from the ADD TYPE menu, DB–Access displays one or two submenus for that category.
ADD TYPE Category | Data Type Submenu | Additional Submenu |
---|---|---|
Numeric | Integer | |
Smallint | ||
Decimal | ||
Float | Smallfloat or Float | |
Char | Char (press C to select) | |
Nchar (press N to select) | ||
Variable-length | Varchar | Varchar (press V to select) |
Nvarchar (press N to select) | ||
Text or Byte | Table | |
Blobspace |
If you use character data in a default locale, select Char for fixed-length data or Varchar if the table will have varying-length entries in that column.
If you use a nondefault locale, select Nchar for fixed length or Nvarchar for varying length.
If you select VARIABLE-LENGTH TEXT or BYTE data type, perform one of the following actions to indicate where that large-object data should reside:
Always select Table for databases that reside on Extended Parallel Server.
DB–Access displays the SELECT BLOBSPACE screen, as Figure 49 shows. Use the arrow keys to choose a blobspace from the alphabetical list or type the blobspace name at the top of the screen.
If you select any of the following data types for the column, a new ADD screen appears. Enter the appropriate information in the Length field.
DB–Access can construct only a nonclustered, ascending B-tree column index. Select the Yes option to create this type of index with the ADD INDEX menu, as Figure 50 shows.
ADD INDEX clients : Yes No Specifies that this column will NOT have an index. ----- Page 1 of 1 ----- mydata@mydbserv ----------- Press CTRL-W for Help ---- Column Name Type Length Index Nulls customer_num Serial 101
DB–Access displays an ADD DUPLICATES screen. Press RETURN or the Y key to allow duplicate values, and the word Dups appears in the Index field. Press the N key to prevent duplicate values. The word Unique appears in the Index field.
DB–Access displays the ADD FILL FACTOR PERCENTAGE screen, as Figure 51 shows.
If you do not want to index the values in this column or if you want any other type of index, such as an R-tree index, select the No option. You must create an R-tree index directly with SQL.
Use the ADD FILL FACTOR PERCENTAGE screen, as Figure 51 shows, to set the fill-factor percentage when you create an index on a single column. The index column has fill factor and Unique or Dups abbreviated to U or D.
ADD FILL FACTOR PERCENTAGE >>
Enter the fill factor percentage. RETURN adds it.
----- Page 1 of 1 -------personnel ------------- Press CTRL-W for Help -----
Column Name Type Length Index Nulls
empl_num Integer U
70% No
last_name Char 20 D 90% No
insurance Integer Dups Yes
ss_num Integer Unique No
Enter any positive value to a maximum of 100. A value less than 1 or greater than 100 results in an error.
If you press RETURN without entering a value, the index will have the fill-factor percentage set in the database server ONCONFIG file. If ONCONFIG has no fill-factor setting, the index will have the default fill-factor value of 90 percent.
Specify whether the column allows null values on the ADD NULLS menu, as Figure 52 shows.
ADD NULLS clients : Yes No Permits null values in this column. ---- Page 1 of 1 ----- mydata@mydbserv --------- Press CTRL-W for Help ---- Column Name Type Length Index Nulls customer_num Serial 101 Unique
Select Yes to allow null values in the column or No to force the column to always have a non-null value.
To add another column definition to the table or return to the CREATE TABLE menu, press Interrupt, an arrow key, or RETURN.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]