Table Editor Tasks
This section explains the tasks that you perform with Table Editor. The tasks are divided into the following categories:
*Note: You cannot save the changes to the structure of a table if any queries in SQL Editor are holding the table “open.” Close the SQL Editor holding open the table then save the changes.
General Tasks
General tasks apply to the overall use of the tool.
Getting Started
Data
Columns Tasks
Column tasks apply to the Columns page.
Indexes Tasks
Index tasks apply to the Indexes page.
Foreign Keys Tasks
Foreign keys tasks apply to the Foreign Keys page.
SQL View Tasks
SQL view tasks apply to the SQL View page.
General Tasks
1
2
Expand the Engines and Databases nodes in PSQL Explorer.
3
4
Click New > Table and type the name for new table.
*Tip: For a list of database object lengths and invalid characters, see Identifier Restrictions by Identifier Type in Advanced Operations Guide.
Note that in the same directory, no two files should share the same file name and differ only in their file name extension. For example, do not create a table (data file) Invoice.btr and another one Invoice.mkd in the same directory. This restriction applies because the database engine uses the file name for various areas of functionality while ignoring the file name extension. Since only the file name is used to differentiate files, files that differ only in their file name extension look identical to the database engine.
5
Click Finish.
1
2
Expand the Engines and Databases nodes in PSQL Explorer.
3
1
2
Click the Columns page tab.
1
2
Click the Indexes page tab.
1
2
Click the Foreign Keys page tab.
1
2
Click the SQL View page tab.
1
2
3
If the Grid is empty but the table contains data, right-click any row in the Grid then click Refresh.
Note that the Grid allows you to directly change database data by changing the values in the grid cells. See Grid Tasks.
1
Note that you cannot undo or redo changes to a table once the table has been saved.
1
Click File > Save or click .
*Note: You cannot save the changes to the structure of a table if the table is open in SQL Editor. Close the SQL Editor referencing the table then save the changes.
Note that you cannot undo or redo changes to tables once the tables have been saved.
1
Click File > Save All.
*Note: You cannot save the changes to the structure of a table if the table is open in SQL Editor. Close the SQL Editors referencing the tables then save the changes.
1
If multiple actions have occurred since the last save, you can repeatedly click the undo or redo toolbar buttons. When no more actions are available for undo or redo, the toolbar button becomes disabled.
Note that you cannot undo or redo changes to a table once the table has been saved.
Columns Tasks
1
2
Right-click an existing column row above which you want to insert a new column.
3
Click Insert Column.
The new column appears above the existing column row. The default name of the inserted column is “columnn,” where “n” is a number that automatically increments by one. (The first column you insert is column0, the second column1 and so forth.)
*Tip: You can also insert a column by clicking an existing column row, then pressing Ctrl+Insert or clicking . Repeating either action inserts a series of columns in succession.
4
Click File > Save or before changing pages within Table Editor.
1
2
or
Click the “Column Name” cell on the empty column row below the last existing column row and start typing a name for the column.
The default name of the inserted column is “columnn,” where “n” is a number that automatically increments by one. (The first column you insert is column0, the second column1 and so forth.)
*Tip: You can also insert a column at the end by clicking or pressing Ctrl+Insert.

Repeating either action inserts a series of columns in succession. The insert action automatically adds the new column to the end.
3
Click File > Save or before changing pages within Table Editor.
1
2
To select multiple columns, press and hold Shift or Ctrl then click for the desired additional columns.
1
2
3
Click Drop Column.
*Tip: You can also delete a column by clicking an existing column row, then pressing Ctrl+Delete or clicking .
You can also delete multiple columns by selecting multiple columns rows. See To select a column or multiple columns.
4
Click File > Save or before changing pages within Table Editor.
1
2
Click in the Column Name cell for the desired column.
3
4
*Tip: For a list of database object lengths and invalid characters, see Identifier Restrictions by Identifier Type in Advanced Operations Guide.
Also, as a general rule, avoid using reserved words for column names. See Reserved Words in SQL Engine Reference. See also SQL Grammar Support in ODBC Guide.
5
Click File > Save or before changing pages within Table Editor.
The data in your database is converted if you change a column data type. For a listing of data types, see PSQL Supported Data Types in SQL Engine Reference.
Changing a column data type sets the defaults for that type on the following: size, scale, precision, default, and collate.
1
2
Click in the Type cell for the desired column.
3
4
5
6
Click File > Save or before changing pages within Table Editor.
*Note: Changing a data type on a column that contains a default value causes the default value to be cleared; reset the value if necessary.
Data in your database is truncated if you change the column to a smaller size for the following data types:
 
1
2
Click in the Size cell for the desired column.
You can set a size only for applicable data types, such as CHAR. If size is not applicable, the grid cell is shaded and you will be unable to edit the Size.
3
4
5
Click File > Save or before changing pages within Table Editor.
Precision specifies the number of significant digits for floating point values.
1
2
Click in the Precision cell for the desired column.
You can set precision only for applicable data types, such as DECIMAL. If precision is not applicable, the grid cell is shaded and you will be unable to edit the Precision.
3
4
5
Click File > Save or before changing pages within Table Editor.
Scale specifies the number of significant digits that are to the right of the decimal point for floating point values.
1
2
Click in the Scale cell for the desired column.
You can set a scale value only for applicable data types, such as NUMERIC. If scale is not applicable, the grid cell is shaded and you will be unable to edit the Scale.
3
4
5
Click File > Save or before changing pages within Table Editor.
For additional information about nulls, see Rebuild Utility Concepts in Advanced Operations Guide, INSERT in SQL Engine Reference, and Null Value in the PSQL Programmer's Guide, which is part of the PSQL Software Developer’s Kit (SDK).
1
2
Click the option box in the Null cell for the desired column.
You can allow nulls only for applicable data types. A shaded square indicates that null values do not apply to the data type.
Also see Null Values.
3
Click File > Save or before changing pages within Table Editor.
Case sensitivity does not apply if the key uses an alternate collating sequence (ACS). You cannot specify case sensitivity and use an ACS.
1
2
Click the option box in the Case cell for the desired column.
You can set a collating sequence only for applicable data types. A shaded square indicates that case sensitivity does not apply to the data type.
By default, PSQL is case sensitive when sorting string keys. Uppercase letters are sorted before lowercase letters. If you specify case insensitive, values are sorted without distinguishing case.
3
Click File > Save or before changing pages within Table Editor.
For additional information about collating sequences, see Manipulating Btrieve Data Files with Maintenance in Advanced Operations Guide and Alternate Collating Sequences in the PSQL Programmer's Guide, which is part of the PSQL Software Developer’s Kit (SDK).
If you use an alternate collating sequence (ACS), you cannot specify case sensitivity. Case sensitivity does not apply if the key uses an ACS.
1
2
Click in the Collate cell for the desired column.
You can set an alternating collating sequence (ACS) only for applicable data types. If collating sequence is not applicable, the grid cell is shaded and you will be unable to edit the Collate cell.
3
4
PSQL supplies an ACS file, upper.alt, in the Samples folder. (See Where are the PSQL files installed? in Getting Started With PSQL.) To use this file, you would type file_path\PSQL\samples\upper.alt.
Upper.alt treats upper and lower case letters the same for sorting. For example, if a database has values abc, ABC, DEF, and Def, inserted in that order, the sorting with upper.alt returns as abc, ABC, DEF, and Def. (The values abc and ABC, and the values DEF and Def are considered duplicates and are returned in the order in which they were inserted.) Normal ASCII sorting sequences upper case letters before lower case, such that the sorting would return as ABC, DEF, Def, abc.
5
Click File > Save or before changing pages within Table Editor.
The default value is used if you perform an SQL INSERT for a row but do not provide a value for the column.
1
2
Click in the Default cell for the desired column.
You can set a default only for applicable data types. If a default is not applicable, the grid cell is shaded and you will be unable to edit the Default.
3
4
The column default can be a scalar function for certain data types:
See also NOW ( ) and CURDATE ( ), both in SQL Engine Reference.
See also NOW ( ) and CURTIME ( ) in SQL Engine Reference.
See also NOW ( ) in SQL Engine Reference.
1 The names are case insensitive. NOW() and now() are equivalent. The parentheses are required. That is, NOW is invalid but NOW() is valid.
5
Click File > Save or before changing pages within Table Editor.
Note that you cannot set a primary key on a column that allows NULLs.
1
2
To select multiple columns, press and hold Shift or Ctrl then click for the desired additional columns.
3
If the column(s) is not a primary key, the action sets the column(s) as a primary key.
If the column, or if any of the columns when multiple columns are selected, is already a primary key, the action removes the setting from all columns.
For example, suppose that column 1 is a primary key and you want columns 1, 2, and 3 to be the primary key. You press and hold Ctrl then click columns 1, 2, and 3. When you click the primary key icon, it is removed from column 1 but not added to columns 2 and 3. If you click the primary key icon again, then columns 1, 2, and 3 are designated as primary keys.
4
Click File > Save or before changing pages within Table Editor.
Index Tasks
Only the database engine can add an index to an IDENTITY or SMALLIDENTITY column. However, you can include an IDENTITY or SMALLIDENTITY column as part of a multiple-segment index.
Table Editor permits you to include an IDENTITY or a SMALLIDENTITY column in the Indexes list if you have not saved the table. However, the DBMS returns an error when you attempt to save the table. After you delete the IDENTITY or SMALLIDENTITY column from the list, you may then save the table.
1
2
Click Add.
The New Index dialog displays.
3
*Tip: For a list of database object lengths and invalid characters, see Identifier Restrictions by Identifier Type in Advanced Operations Guide.
The new index appears in the Indexes list and the Index Segment Details display. Note that the first column is populated into the Columns list.
*Note: New indexes are created by default as Normal.
4
In the Columns list, select the Column to designate for the Index or Index Segment.
*Caution: Indexes must have at least one Column designated. If you do not select a Column for the Index, the first column remains selected.
The default sort order is Ascending. If you need a descending sort order, select Descending from the Sort Order list for the Column you want changed.
*Note: Some data types, such as LONGVARBINARY, cannot be used for an index. Columns with such data types are not valid choices.
5
Note that a column can be selected for an index only once. Once selected, the column is removed from the list of choices because the column has already been designated in the index.
6
Click File > Save or before changing pages within Table Editor.
See also Creating Indexes in PSQL Programmer's Guide, which is part of the PSQL Software Developer’s Kit (SDK).
Only the database engine can add an index to an IDENTITY or SMALLIDENTITY column. However, you can include an IDENTITY or SMALLIDENTITY column as part of a multiple-segment index.
Table Editor permits you to include an IDENTITY or a SMALLIDENTITY column in the Indexes list if you have not saved the table. However, the DBMS returns an error when you attempt to save the table. After you delete the IDENTITY or SMALLIDENTITY column from the list, you may then save the table.
1
2
Click Add.
The New Index dialog displays.
3
*Tip: For a list of database object lengths and invalid characters, see Identifier Restrictions by Identifier Type in Advanced Operations Guide.
The new index appears in the Indexes list and the Index Segment Details display.
*Note: New indexes are created by default as Normal.
4
Select Unique in the Index Segment Details area to designate the index as unique.
Selecting Unique disables duplicatability, restricting duplicates.
Note that the first column is populated into the Columns list.
5
In the Columns list, select the Column to designate for the Index or Index Segment.
*Caution: Indexes must have at least one Column designated. If you do not select a Column for the Index, the first column remains selected.
The default sort order is Ascending. If you need a descending sort order, select Descending from the Sort Order list for the Column you want changed.
*Note: Some data types, such as LONGVARBINARY, cannot be used for an index. Columns with such data types are not valid choices.
6
Note that a column can be selected for an index only once. Once selected, the column is removed from the list of choices because the column has already been designated in the index.
7
Click File > Save or before changing pages within Table Editor.
See also Creating Indexes in PSQL Programmer's Guide, which is part of the PSQL Software Developer’s Kit (SDK).
Only the database engine can add an index to an IDENTITY or SMALLIDENTITY column. However, you can include an IDENTITY or SMALLIDENTITY column as part of a multiple-segment index.
Table Editor permits you to include an IDENTITY or a SMALLIDENTITY column in the Indexes list if you have not saved the table. However, the DBMS returns an error when you attempt to save the table. After you delete the IDENTITY or SMALLIDENTITY column from the list, you may then save the table.
1
2
Click Add.
The New Index dialog displays.
3
*Tip: For a list of database object lengths and invalid characters, see Identifier Restrictions by Identifier Type in Advanced Operations Guide.
The new index appears in the Indexes list and the Index Segment Details display.
*Note: New indexes are created by default as Normal.
4
Select Partial in the Index Segment Details area to designate the index as partial.
Note that the first column is populated into the Columns list.
5
In the Columns list, select the Column to designate for the Index or Index Segment.
*Caution: Indexes must have at least one Column designated. If you do not select a Column for the Index, the first column remains selected.
The default sort order is Ascending. If you need a descending sort order, select Descending from the Sort Order list for the Column you want changed.
*Note: Partial Indexes are restricted to columns with a data type of CHAR or VARCHAR and that are designated as the only or last segment in an Index.
6
Note that a column can be selected for an index only once. Once selected, the column is removed from the list of choices because the column has already been designated in the index.
7
Click File > Save or before changing pages within Table Editor.
See also Creating Indexes in PSQL Programmer's Guide, which is part of the PSQL Software Developer’s Kit (SDK).
The database engine creates some indexes, such as IDENTITY column indexes and primary key indexes. These indexes are read-only and cannot be modified.
Table Editor permits you to include an IDENTITY or a SMALLIDENTITY column in the Indexes list if you have not saved the table. However, the DBMS returns an error when you attempt to save the table. After you delete the IDENTITY or SMALLIDENTITY column from the list, you may then save the table.
1
2
The Index Segment Details displays.
3
4
Click File > Save or before changing pages within Table Editor.
The database engine creates some indexes, such as IDENTITY column indexes and primary key indexes. These indexes are read-only and cannot be deleted.
1
2
3
4
Click Yes to confirm the deletion.
5
Click File > Save or before changing pages within Table Editor.
For detailed information about segments, see Segmentation in the PSQL Programmer's Guide, which is part of the PSQL Software Developer’s Kit (SDK).
Only the database engine can add an index to an IDENTITY or a SMALLIDENTITY column. However, you can include an IDENTITY or a SMALLIDENTITY column as part of a multiple-segment index. See also AUTOINC in SQL Engine Reference.
1
2
The Index Segment Details displays and lists the selected Index Segments.
3
4
*Note: Some data types, such as LONGVARBINARY, cannot be used for an index. Columns with such data types are not valid choices.
The default sort order is Ascending. If you need a descending sort order, select Descending from the Sort Order list for the Column you want changed.
5
Note that a column can be selected for an index only once. Once selected, the column is removed from the list of choices because the column has already been designated in the index.
6
Click File > Save or before changing pages within Table Editor.
For detailed information about segments, see Segmentation in the PSQL Programmer's Guide, which is part of the PSQL Software Developer’s Kit (SDK).
Only the database engine can add an index to an IDENTITY or a SMALLIDENTITY column. However, you can include an IDENTITY or a SMALLIDENTITY column as part of a multiple-segment index. See also AUTOINC in SQL Engine Reference.
1
2
The Index Segment Details displays.
3
4
From the Columns list, click the desired column designated as the index segment.
*Note: Some data types, such as LONGVARBINARY, cannot be used for an index. Columns with such data types are not valid choices.
The default sort order is Ascending. If you need a descending sort order, select Descending from the Sort Order list for the Column you want changed.
5
Note that a column can be selected for an index only once. Once selected, the column is removed from the list of choices because the column has already been designated in the index.
6
Click File > Save or before changing pages within Table Editor.
*Note: Each index requires a minimum of one segment. To delete an index that has only one segment, delete the index itself.
1
2
The Index Segment Details displays, listing all the designated index segments.
3
4
With the index segment you want to delete selected, click Delete in the Index Segment Details Columns list.
5
Click File > Save or before changing pages within Table Editor.
1
2
The Index Segment Details displays.
3
4
Click Up to move the segment toward the top of the segment grouping, or Down to move the segment toward the bottom.
5
Click File > Save or before changing pages within Table Editor.
For detailed information about sort order, see Sort Order in the PSQL Programmer's Guide, which is part of the PSQL Software Developer’s Kit (SDK).
1
2
The Index Segment Details displays.
3
4
From the Sort Order list, click Ascending or Descending.
The default sort order when an index segment is created is ascending.
5
Click File > Save or before changing pages within Table Editor.
For detailed information about duplicates, see Duplicatability in the PSQL Programmer's Guide, which is part of the PSQL Software Developer’s Kit (SDK).
1
2
The Index Segment Details displays.
3
Clear the Unique option in the Index Segment Details area by selecting one of the other options (Partial or Normal).
*Note: By default, indexes are created as Normal, allowing duplicates.
4
Click File > Save or before changing pages within Table Editor.
For detailed information about modifiability, see Modifiability in the PSQL Programmer's Guide, which is part of the PSQL Software Developer’s Kit (SDK).
1
2
The Index Segment Details displays.
3
Click Allow Modifications option.
A check mark in the box indicates that the index value can be modified. Lack of a check mark indicates that the index value cannot be modified.
 
The default for all SQL data types is that the index column is modifiable.
4
Click File > Save or before changing pages within Table Editor.
Foreign Keys Tasks
Note that at least one table in the database must have a primary key or you cannot add a foreign key.
1
2
Click Add.
3
*Tip: For a list of database object lengths and invalid characters, see Identifier Restrictions by Identifier Type in Advanced Operations Guide.
4
The new foreign key appears in the Foreign Keys list and the Foreign Keys Details display.
5
6
The primary field(s) in the table appear in “Primary Table Fields” column.
7
Click the empty cell in the “Foreign Table Fields” column for the corresponding field in the “Primary Table Fields,” then click to displays the list of permissible fields.
*Note: The data type and size of the fields must match. The list of Foreign Table Fields contains only fields that are the same data type and size as the primary table field being matched.
8
9
Repeat steps 7 and 8 to match each field listed in the “Primary Table Fields” column with a field in the “Foreign Table Fields” column.
10
Click the desired referential integrity rule: Delete Restrict or Delete Cascade.
PSQL allows a circular delete cascade on a table that references itself. Because of this, use delete cascade with caution. See Delete Restrict and Delete Cascade, both in Advanced Operations Guide.
11
Click File > Save or before changing pages within Table Editor.
1
2
3
4
See steps 5 through 10 in To add a foreign key.
5
Click File > Save or before changing pages within Table Editor.
1
2
3
Click Delete.
4
Click Yes to confirm the deletion.
5
Click File > Save or before changing pages within Table Editor.
SQL View Tasks
1
2
Position the cursor in the desired statement view: CREATE Statement or ALTER Statement.
3
*Tip: You can press Ctrl+A to select all of the text.
4
Right-click then click Copy (or press Ctrl+C).
1
2
For the desired statement view, CREATE Statement or ALTER Statement, click the icon in the upper right corner of the view: