PROJECT (Short Name: PROJ)
Top  Previous  Next

Use the PROJECT command to create a new table from an existing table or view.

project

Options

ORDER BY clause

Sorts rows of data. For more information, see the "ORDER BY" entry.

tblname1 FROM tblview

Tblname1 is the name of the new table you want to create, and FROM tblview specifies the existing table or view you want to copy.

TEMPORARY

Allows you to create a Temporary Table with the PROJECT command.

USING
*
Specifies to use all columns with the command.

USING collist

Specifies the column(s) to use with the command.

WHERE clause

Limits rows of data. For more information, see the "WHERE" entry.

About the PROJECT Command

The new table can be a copy of an existing table, a copy of an existing table with the rows sorted in a different order, a duplicate of a table structure without any data, or a table that contains specific rows and columns from an existing table.

You must include the USING clause with the PROJECT command. The USING clause specifies the columns to be included in the new table. If you want the new table to include all the columns from an existing table, use an asterisk (*) in the clause. If you want the new table to include only specific columns from the existing table, list them in the order you want them to appear in the new table. If you want the new table to include all columns in a different order, list them in the order you want them to appear.

Working with Computed Columns
R:BASE copies the data from each column into the new table. If a computed column is included, R:BASE transfers the current values in the computed column to the new table. In order to calculate computed values in the column in the new table, R:BASE needs the column names used in the computed column's expression. Therefore, include those column names in the USING clause before the computed column. When you do not include those column names in the USING clause before the computed column, R:BASE makes the computed column a regular column, assigns a data type, and displays a message suggesting you rename the column in the new table. If you do not rename the column, the new table has a column with the same name as the column in the original table, but does not have the designation COMPUTED. You will not be able to use the BACKUP and UNLOAD commands, because you cannot have a computed column and a regular column with the same name.

Working with Autonumbered Columns
In a new table, R:BASE does not update the value in a row for the autonumber column. The autonumber column becomes a regular column.

Removing Columns and Rows from a Table
PROJECT is also useful if you want to remove several columns or rows from a table. To delete columns from a table, create a new table that retains the columns you want to keep, or to delete rows, create a new table using a WHERE clause. Use the DROP command to remove the table you no longer want, then use the RENAME command to give the new table the original table's name.

Transferring Default Column Definitions
Default column definitions are not transferred to a new table. When rows are added to the new table with the INSERT command, they are given a null value. If you want a default column definition, define the default column again.

Examples

The following command creates a new table that is a duplicate of the employee table.

PROJECT reps FROM employee USING *

The following command creates a table named empty that has the same structure as the prodlocation table but contains no rows of data.

PROJECT empty FROM prodlocation USING * WHERE LIMIT=0

The example below creates a table named gt5year. The order of the columns in the gt5year table are specified in the USING clause. The WHERE clause specifies that only the information for employees hired before January 1, 1984 will be selected. The ORDER BY clause sorts the rows in alphabetical order by the employees' last names.

PROJECT gt5year FROM employee USING empfname, emplname, + 
empid, empext, hiredate WHERE hiredate < '01/01/84' +
ORDER BY emplname