Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Command Index > P

PROJECT (Short Name: PROJ)

Scroll Prev Top Next More

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

 

PROJECT

 

Options

 

*

Specifies to use all columns with the command.

 

ALL

Specifies to use all columns with the command.

 

collist

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

 

EXCEPT

Specifies the column(s) which will not be included in the projected table.

 

ORDER BY clause

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

 

SELECT clause

Specifies the columns and one or more tables or views from which to create the new table. Using the SELECT portion it is not necessary to create a view first in order to perform PROJECT into a new table from multiple table joins. A USING clause is not needed as all required columns are defined in the SELECT statement.

 

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.

 

WHERE clause

Limits rows of data. For more information, see WHERE.

 

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, a table that contains specific rows and columns from an existing table, or a SELECT clause which specifies the columns and one or more tables or views from which to create the new table.

 

When not using SELECT, 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 transferred to a new table. If you want to change the projected default column definition, define the desired default column definition with the ALTER TABLE command.

 

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 EmpHires. The order of the columns in the EmpHires table are specified in the USING clause. The WHERE clause specifies that only the information for employees hired before January 1, 2020 will be selected. The ORDER BY clause sorts the rows in alphabetical order by the employees' last names.

 

PROJECT EmpHires FROM Employee USING EmpFName, EmpLName, +

EmpID, EmpExt, HireDate WHERE HireDate < '01/01/2020' +

ORDER BY EmpLName

 

The following create a new table from the Staff and Departments table, with the SELECT statement to specify the column and table source.

 

PROJECT StaffDepts FROM +

SELECT T2.DepartmentID,T2.Description,T2.OwnerDept,+

T1.LastName,T1.FirstName,T1.PhoneExt,T2.DeptShape +

FROM Staff T1,Departments T2 +

WHERE T1.DepartmentID = T2.DepartmentID

 

The following creates a temporary table CustDetails with all Customer table columns except CustFax.

 

PROJECT TEMPORARY CustDetail FROM Customer USING * EXCEPT CustFax