将新列添加到表中 [英] Adding new column to a table

查看:73
本文介绍了将新列添加到表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在特定列的现有表格中添加新列

位置...


现有表格定义:

MyTable(Col1,Col2,Col3)


我想在MyTable中添加一个新列,新列的位置是
$在Col2和Col3之间的b $ b:

MyTable(Col1,Col2,New_Column,Col3)


" Alter Table MyTable Add Column ..." ;声明将列添加到

结尾(即MyTable(Col1,Col2,Col3,New_Column))。

我可以删除表并重新创建它,但我想要知道是否可以以任何其他方式完成

。谢谢你的帮助。

A Carter

解决方案

一个************* @ gmail.com 写道:


我想在特定列的现有表格中添加新列

位置...


现有表定义:

MyTable(Col1,Col2,Col3)


我想在MyTable中添加一个新列,新列'的位置是<在Col2和Col3之间的


MyTable(Col1,Col2,New_Column,Col3)


"更改表MyTable添加列..."声明将列添加到

结尾(即MyTable(Col1,Col2,Col3,New_Column))。

我可以删除表并重新创建它,但我想要知道是否可以以任何其他方式完成

。谢谢你的帮助。

A Carter



为什么你想要除了ALTER ADD以外的任何其他方式?

这是即时的和在线....


干杯

Serge


-

Serge Rielau

DB2解决方案开发

IBM多伦多实验室


IOD会议
http://www.ibm.com/software/data/ond ... ness / conf2006 /


an*************@gmail.com 写道:


我想添加一个新列到特定列的现有表格

位置...


现有表格定义:

MyTable(Col1,Col2, Col3)


我想在MyTable中添加一个新列,并且在Col2和Col3之间新列的位置是



MyTable(Col1,Col2,New_Column,Col3)


" Alter Table MyTable Add Column ..."声明将列添加到

结尾(即MyTable(Col1,Col2,Col3,New_Column))。

我可以删除表并重新创建它,但我想要知道是否可以以任何其他方式完成

。谢谢你的帮助。



表由一组列组成。因此,列顺序

在概念上完全无关紧要。您可以在查询中选择

列的任何订单。


-

Knut Stolze

DB2信息集成开发

IBM德国


感谢您的回复。这是情况...


我在

数据库的每个表中都有审计列(例如,update_user_id)。我希望将此审核列保留为最后一栏,当我执行描述表格TableName时或者从表名中选择*。


但是,当我向表中添加一个新列时,它会在最后一个

列之后添加。 。是否可以在两者之间插入新栏目?


谢谢

卡特


I''d like to add a new column to an existing table at a specific column
location...

Existing table definition:
MyTable(Col1, Col2, Col3)

I want to add a new column in MyTable and the new column''s position is
in between Col2 and Col3:
MyTable(Col1, Col2, New_Column, Col3)

"Alter Table MyTable Add Column ..." statement adds the column to the
end (i.e. MyTable(Col1, Col2, Col3, New_Column) ).
I can drop the table and recreate it, but I would like to know whether
it can be done in any other way. Thanks for your help.
A Carter

解决方案

an*************@gmail.com wrote:

I''d like to add a new column to an existing table at a specific column
location...

Existing table definition:
MyTable(Col1, Col2, Col3)

I want to add a new column in MyTable and the new column''s position is
in between Col2 and Col3:
MyTable(Col1, Col2, New_Column, Col3)

"Alter Table MyTable Add Column ..." statement adds the column to the
end (i.e. MyTable(Col1, Col2, Col3, New_Column) ).
I can drop the table and recreate it, but I would like to know whether
it can be done in any other way. Thanks for your help.
A Carter

Why would you want any other way than ALTER ADD?
It''s instantanious and online....

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/


an*************@gmail.com wrote:

I''d like to add a new column to an existing table at a specific column
location...

Existing table definition:
MyTable(Col1, Col2, Col3)

I want to add a new column in MyTable and the new column''s position is
in between Col2 and Col3:
MyTable(Col1, Col2, New_Column, Col3)

"Alter Table MyTable Add Column ..." statement adds the column to the
end (i.e. MyTable(Col1, Col2, Col3, New_Column) ).
I can drop the table and recreate it, but I would like to know whether
it can be done in any other way. Thanks for your help.

A table is comprised of a set of columns. Therefore, the column order is
completely irrelevant conceptually. You can choose any order of the
columns in your query.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany


Thanks for replies. Here is the situation...

I have audit column (for example, update_user_id) in every table in the
database. I''d like to keep this audit column as the last column when I
execute "describe table TableName" or "select * from TableName".

But, when I add a new column to a table, it is added after the last
column...is it possible to ''insert'' the new column in between?

Thanks
A Carter


这篇关于将新列添加到表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆