Discussion:
How to change the Table Name and column Name.
(too old to reply)
b***@yahoo.co.in
2007-08-09 08:29:02 UTC
Permalink
Hi,

I want to change the column name of the table and Table Name, want to know the verison of the DB2 installed in server.

Existing table Name is TEST, i want to change it to TEST1
one Coulmn in the table is column1, i want to change it to column2

Please help me.

Thanks
Kiran
Knut Stolze
2007-08-13 07:57:05 UTC
Permalink
Post by b***@yahoo.co.in
Hi,
I want to change the column name of the table and Table Name, want to know
the verison of the DB2 installed in server.
I'm assuming you use DB2 for Linux, Unix, and Windows.

DB2 version: use the "db2level" utility.

Renaming a table: SQL statement RENAME TABLE
(http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0000980.htm)

Renaming a column: add new column, copy data from old to new with, then drop
old column.

A much simpler approach for table/column name change is to add a view over
your table. The view can have the desired name and rename the column. You
have next to no overhead (just some tiny piece during SQL statement
compilation).
--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Continue reading on narkive:
Loading...