SQL Table数据类型修改 [英] SQL Table datatype modify

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

问题描述

如何使用sql脚本修改表中特定列的数据类型

How to modify the datatype of a particular column in a table using sql scripts

推荐答案

可能使用以下代码段".

Probably using Below Snippet.

ALTER TABLE table_name
 MODIFY column_name column_type;



或者您可以参考全文,
http://www.techonthenet.com/sql/tables/alter_table.ph [ ^ ]

如果有帮助,请 投票 接受答案 .



Or you could refer full article,
http://www.techonthenet.com/sql/tables/alter_table.ph[^]

Please vote and Accept Answer if it Helped.


数据将如果某些数据类型的字段类型更改,则将被截断.

也并非所有字段都可以更改

以下是alter column数据类型的示例

Data will be truncated in case field type is changed for some data types.

also not all fields can be changed

following is the example of alter column datatype

Create table testTable (field1 int)
--to convert integer field to varchar
alter table testTable alter column field1 varchar(20)


我认为Hiren为该问题给出了正确答案.
I think Hiren given right answer for the question.


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

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