将数据类型int更改为float [英] change datatype int to float
本文介绍了将数据类型int更改为float的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张桌子
i have one table
id name marks
1 aaa 50
2 bbb 60
和标记数据类型是int默认值0
现在我有更改数据类型浮动
and marks datatype is int default 0
and now i have change datatype float
ALTER TABLE AAA
ALTER COLUMN marks float
现在我收到错误
ALTER TABLE ALTER COLUMN标记失败,因为一个或多个对象访问此列。 />
让我知道如何更改数据类型
感谢提前
now i get error
ALTER TABLE ALTER COLUMN marks failed because one or more objects access this column.
give me idea how to change datatype
thanks to advance
推荐答案
I猜你对这个专栏有限制。看看这里的讨论:
http://stackoverflow.com/questions/9866989/alter-table-on-dependant-column [ ^ ]
http://social.msdn.microsoft.com/Forums/sqlserver/en-US / 9ca4e7b6-7ae8-4bf2-963e-23cc935b4b9c / modify-column-datatype-length [ ^ ]
I guess you have constraints on this column. Look at the discussion here:
http://stackoverflow.com/questions/9866989/alter-table-on-dependant-column[^]
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/9ca4e7b6-7ae8-4bf2-963e-23cc935b4b9c/modify-column-datatype-length[^]
为此您需要删除已实现的表约束优先。喜欢
ALTER TABLE table2
DROP CONSTRAINT FK_table2_table1;
ALTER TABLE table1
DROP CONSTRAINT PK_table1;
ALTER TABLE table1
ALTER COLUMN column1 nvarchar(32)NOT NULL;
ALTER TABLE table2
ALTER COLUMN column1 nvarchar(32);
ALTER TABLE table1
ADD CONSTRAINT PK_table1
PRIMARY KEY(column1,column2)
ALTER TABLE table2
ADD CONSTRAINT FK_table1_table2
FOREIGN KEY(column1,column2)
REFERENCES table1(column1,column2)
For that you need to remove realted Table Constrain First. Like
ALTER TABLE table2
DROP CONSTRAINT FK_table2_table1;
ALTER TABLE table1
DROP CONSTRAINT PK_table1;
ALTER TABLE table1
ALTER COLUMN column1 nvarchar(32) NOT NULL;
ALTER TABLE table2
ALTER COLUMN column1 nvarchar(32);
ALTER TABLE table1
ADD CONSTRAINT PK_table1
PRIMARY KEY (column1, column2)
ALTER TABLE table2
ADD CONSTRAINT FK_table1_table2
FOREIGN KEY (column1, column2)
REFERENCES table1(column1, column2)
这篇关于将数据类型int更改为float的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文