表数据类型更改 [英] Table Data Type Alter

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

问题描述

我创建了一个名为items的表,并将名称插入为int,并且错误地将长度提供为255类型,但现在我想更改表结构并以--p方式运行查询

ALTER TABLE项目 ALTER COLUMN名称varchar(255);但这并没有改变表格我需要在表格中更改的内容.helpplz

解决方案

有两种方法

ALTER TABLE t1 CHANGE <column_name> <column_name> <type> 

注意:您必须两次写入列名 或

ALTER TABLE t1 MODIFY <column_name> <type> ;

参考

I created a table named items and inserted name as int and provided the length as 255 type by mistake but now i wanted to alter the table structure and run the query as--

ALTER TABLE items ALTER COLUMN name varchar(255); but it is not altering the table what i need to change in the table.help plz

解决方案

there are two ways

ALTER TABLE t1 CHANGE <column_name> <column_name> <type> 

note: you have to write column name twice OR

ALTER TABLE t1 MODIFY <column_name> <type> ;

Reference

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

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