在同一查询中更改列和添加列的语法

发布于 2024-08-23 04:56:18 字数 268 浏览 4 评论 0原文

是否可以在 MSQL 的同一个更改表查询中更改列并添加新列?我尝试查看下面的 MSDN 文章,但理解起来有点混乱。我可以轻松地使用多个查询来完成此操作,但如果可能的话,我宁愿使用一个查询来完成此操作。谢谢。

http://msdn.microsoft.com/en-us/library/ms190273。 ASPX

Is it possible to both alter a column and add a new column in the same alter table query for MSQL? I've tried looking at the below MSDN article, but it was a bit confusing to understand. I could easily do it with multiple queries, but would rather do it with one query if possible. Thanks.

http://msdn.microsoft.com/en-us/library/ms190273.aspx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆光下的微笑 2024-08-30 04:56:18

不,您需要分批进行,

create table test(id int)
go

alter table Test add id2 int
go
alter table Test ALTER COLUMN id DECIMAL (5, 2) 

但是您可以一次添加超过 1 列

alter table Test add id3 int, id4 int
go

no you need to do it in separate batches

create table test(id int)
go

alter table Test add id2 int
go
alter table Test ALTER COLUMN id DECIMAL (5, 2) 

you can however add more than 1 column at a time

alter table Test add id3 int, id4 int
go
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文