Monday, November 11, 2019
Tip of the Day: Duplicate a Column Definition with ALTER/CREATE TABLE Commands
Product.......: R:BASE X.5 and R:BASE X.5 Enterprise (Version 10.5)
Build.........: 10.5.2.11111 or higher
Sections......: Commands
Keywords......: ALTER TABLE, CREATE TABLE, DUPLICATE, Column, Definition
Did you know the ALTER TABLE and CREATE TABLE commands were enhanced
to duplicate the definition of a column that already exists in another
table?
The implemented ability will "duplicate" the definition of a column that
already exists in the database in another table. The enhanced syntax uses
"DUPLICATE" as a keyword followed by the table and column name, for which
the column definition is to be duplicated.
The DUPLICATE keyword will copy the data type, length, any default value,
and the NOT NULL flag, if any. It will not support computed columns. It
will also not duplicate any description for the column.
-- ALTER TABLE Example:
ALTER TABLE TSALES_ORDERS +
ADD COLUMN CUST_DESC +
DUPLICATE CUSTOMERS.CUST_DESC
-- CREATE TABLE Example:
CREATE TEMPORARY TABLE Temp1 +
(tEmpID INTEGER, +
tEmpWebAddr DUPLICATE EMPLOYEE.WEBADDRESS, +
tEmpStartDate DATE)
The above will create the column tEmpWebAddr with the same type and default
value as WEBADDRESS in the EMPLOYEE table.
The enhancement is helpful in ALTER TABLE ... ADD COLUMN situations, to be
able to add a column dynamically by creating the column definition from the
attributes of a column in another table.
Very Best R:egards,
Razzak.
https://www.rbase.com
http://www.facebook.com/rbase/
--
For group guidelines, visit
http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rbase-l/201911111620.xABGK2pg025893%40atl4mhob25.registeredsite.com.