增加现有表的数据类型的大小 [英] Increase the size of datatype of existing table

查看:75
本文介绍了增加现有表的数据类型的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将varchar(100)的数据类型增加到varchar(200)?在现有表中没有任何数据丢失的情况下?我正在使用MSSQL

I want to increase the data type of varchar(100) to varchar(200)?without any loss of data in the existing table?I am using MSSQL

推荐答案

是的,您可以这样修改表格,


更改表table_name
ALTER COLUMN col_name varchar(200)


对于MY SQL:

ALTER TABLE table_name
修改列col_name varchar(200)
yes you can do this by just altering your table like this,


Alter Table table_name
ALTER COLUMN col_name varchar(200)


For MY SQL :

ALTER TABLE table_name
MODIFY COLUMN col_name varchar(200)


您正在增加列的大小,因此不应丢失任何数据.您可以直接应用ALTER TABLE命令.
但是,如果您的表包含大量数据,那么它将消耗大量时间.
You are increasing the size of a column, so you should not loose any data. Directly you can apply ALTER TABLE command.
But if your table contains a lot of data, than it will consume a lot of time.
So better idea to CREATE another clone table with column size of varchar(200) with some other name, Move all the data from main table to the new table, DROP the old table and RENAME the new table to main table.


只需go to table design并对其进行更改或编写ALTER TABLE查询.

如果增加大小,则不会影响任何数据.但是,如果减小大小,则可能会丢失数据.

这种情况没问题.
Just go to table design and Change it or write ALTER TABLE query.

If you increase the size it will not affect any data. But, if you decrease the size there is a chance of losing the data.

This case no problem.


这篇关于增加现有表的数据类型的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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