将 INT 更改为 BigInt [英] Changing INT to BigInt

查看:49
本文介绍了将 INT 更改为 BigInt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个仓库表,里面有 16 吨数据.我有几个整数列.我们必须为我们编写的每个查询将这些转换为 BIGINT,因为 SUM 太大而无法放入 INT.

I have a warehouse table with 16 tons of data in it. I have a few Integer columns in it. We have to cast these into BIGINT for every query we write, because the SUM is too large to fit in an INT.

我们现在正在开发一个新的数据集市.所以我们想,为什么不把所有这些列都改成 BIGINT,这样我们就不用担心新的查询集了.

We now have a new datamart under development. So we thought, why not change all these columns into BIGINT and we have less to worry for the new set of queries.

由于数据已经加载,我想我会使用 Management Studio 并更改数据类型.但我首先收到警告:

Since the data is already loaded, I figured I would use Management Studio and change the data type. But I first get a warning:

保存对包含大量数据的表的定义更改可能需要相当长的时间.保存更改时,将无法访问表数据.

然后我得到一个错误:

超时已过.操作完成前超时时间已过或服务器未响应.

我该如何解决这个问题?

How do I get around this?

推荐答案

如果其中一个或多个列对它们没有约束(如外键、索引、默认值、规则等),您应该能够更改每一项都做得很快

If one or more of those columns have no constraints against them (like a foreign key, index, default, rule, etc), you should be able to change each one quickly by doing

ALTER TABLE 怪物 ALTER COLUMN MyIntCol1 bigint

Management Studio 的更改 SQL 很少是最有效的,并且倾向于使用临时表来修改现有列.

Management Studio's change SQL is rarely the most efficient and tends to favour temporary tables for anything modifying an existing column.

这篇关于将 INT 更改为 BigInt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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