无法删除列MSSQL(在Hibernate之后?)

时间:2014-04-09 07:18:34

标签: java sql-server hibernate

我为测试创建了列。现在我想删除它。休眠hbm2ddl.auto = validate

但经过一些测试后,我不能放下柱子。

CMD:

alter table [x].[dbo].[tb_monitor] drop column period;

答案:

Msg 5074, Level 16, State 1, Line 1
The object 'DF__tb_monito__perio__6754599E' is dependent on column 'period'.
Msg 4922, Level 16, State 9, Line 1
ALTER TABLE DROP COLUMN period failed because one or more objects access this column.

这个专栏不是FK。 Hibernate在表中创建了一些依赖吗?

3 个答案:

答案 0 :(得分:2)

DF__tb_monito__perio__6754599E对我来说听起来像default-constraint

答案 1 :(得分:2)

试试这个:

ALTER TABLE [x].[dbo].[tb_monitor]
DROP CONSTRAINT DF__tb_monito__perio__6754599E

alter table [x].[dbo].[tb_monitor] drop column period;

答案 2 :(得分:0)

就我而言validate不会删除列时,您必须使用createcreate-drop。请注意,这将丢弃并重新创建整个数据库。