Files
rdb/man/rename.man
T

135 lines
2.7 KiB
Groff

.TH rename "" "" "/rdb Command"
.PC "Rename a column"
\fBrename [ \fIoldcolumn newcolumn ...\fB ] < \fItableorlist\fR
.PP
.II column^rename
The command
.B rename
changes the name of
.I oldcolumn
to
.I newcolumn
within
.IR tableorlist .
You can name on the command line
as many \fIoldcolumn/newcolumn\fR pairs as you wish.
.SH Example
Consider the table
.BR inventory :
.DM
Item# Amount Cost Value Description
----- ------ ----- ------- --------------
1 3 5.00 15.00 rubber gloves
2 100 0.50 50.00 test tubes
3 5 8.00 40.00 clamps
4 23 1.98 45.54 plates
5 99 2.45 242.55 cleaning cloth
6 89 14.75 1312.75 bunsen burners
7 5 175.00 875.00 scales
.DE
.PP
The command
.DM
rename Amount Qty Description Name < inventory
.DE
.PP
renames
.B Amount
to
.BR Qty ,
and
.B Description
to
.BR Name .
The table now appears as follows:
.DM
Item# Qty Cost Value Name
----- --- ------ ------- --------------
1 3 5.00 15.00 rubber gloves
2 100 0.50 50.00 test tubes
3 5 8.00 40.00 clamps
4 23 1.98 45.54 plates
5 99 2.45 242.55 cleaning cloth
6 89 14.75 1312.75 bunsen burners
7 5 175.00 875.00 scales
.DE
.PP
If you have a list-formatted file, you can also rename the column names.
For example, consider the list
.BR maillist :
.DM
Number 1
Name Ronald McDonald
Company McDonald's
Street 123 Mac Attack
City Memphis
State TENN
ZIP 30000
Phone (111) 222-3333
.DE
.DM
Number 2
Name Chiquita Banana
Company United Brands
Street Uno Avenido de la Reforma
City San Jose
State Costa Rica
ZIP 123456789
Phone 1234
.DE
.PP
The command
.DM
rename Number Num ZIP Zip < maillist
.DE
.PP
changes
.B Number
to
.BR Num ,
and
.B ZIP
to
.BR Zip .
The list now appears as follows:
.DM
Num 1
Name Ronald McDonald
Company McDonald's
Street 123 Mac Attack
City Memphis
State TENN
Zip 30000
Phone (111) 222-3333
.DE
.DM
Num 2
Name Chiquita Banana
Company United Brands
Street Uno Avenido de la Reforma
City San Jose
State Costa Rica
Zip 123456789
Phone 1234
.DE
.SH "Case of Column Names"
.I "(Ruby re-creation only.)"
Column names are case sensitive, as in the original
.BR /rdb .
If the environment variable
.B RDB_ICASE
is set to 1, upper and lower case are ignored when column names are looked up.
An exact match always wins;
if several columns differ only in case, the command stops with an
.I ambiguous
error.
Names that are also
.B awk
reserved words or are followed by
.B (
are never taken for columns.
.SH "See Also"
.B
column
.R