更改 SQL Server 中的数据库列设计 [英] Change Database Column Design in SQL Server

查看:24
本文介绍了更改 SQL Server 中的数据库列设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生产数据库,我需要在列设计中将其从 varchar 更改为 nvarchar.我知道我可以强制它重新创建设计并保存它,但这样做是个好主意吗?

I have a production database which I need to make a change from varchar to nvarchar in the column design. I know I can force it to re-create the design and save it but is it a good idea to do so?

结果可能是什么以及有什么其他建议?

What could be the outcomes and any other suggestions?

更新:它的 SQL Server 2008

Update: Its SQL Server 2008

推荐答案

如果您将使用 Visual Studio 数据库版本来生成部署脚本,则会自动为您创建.但是,它在后面的作用如下
1) 使用新定义创建表.只需使用 {TableName}_new 命名您的表.
2)像在旧表上一样创建索引
3)创建旧表上的触发器(并禁用它们)
4) 将旧表中的数据复制到新表中.
5)通过将_old附加到表名来重命名旧表
6) 通过从名称中删除 _new 来重命名新表

If you would be using Visual Studio Database edition to generate the deployment script this would be automatically created for you. However, what it does in behind is as follows
1) Create table with the new definition. Just name your table with {TableName}_new.
2) Create the indexes as you have on the old table
3) Create The triggers as you had on the old table (and disable them)
4) Copy over the data from the old table to new table.
5) Rename the Old Table by appending _old to the table name
6) Rename the new table by dropping the _new from the name

这篇关于更改 SQL Server 中的数据库列设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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