我为测试创建了列。现在我想删除它。休眠hbm2ddl.auto = validate
。
但经过一些测试后,我不能放下柱子。
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在表中创建了一些依赖吗?
答案 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
不会删除列时,您必须使用create
或create-drop
。请注意,这将丢弃并重新创建整个数据库。