Closed GoogleCodeExporter closed 9 years ago
Test case:
drop table mytest;
drop table mytest_foreign;
create table mytest (k bigint, another_column bigint);
create table mytest_foreign (k bigint primary key);
alter table mytest add constraint mytest_foreign_fk foreign key(k) references
mytest_foreign (k);
alter table mytest drop column k;
This works on PostgreSQL and Apache Derby, but not on HSQLDB and H2.
In MySQL, I get: Error on rename of './test/#sql-10fdb_1' to './test/mytest'
(errno: 150) HY000/1025
The workaround for H2 and HSQLDB is:
alter table mytest drop constraint mytest_foreign_fk;
alter table mytest drop column k;
Original comment by thomas.t...@gmail.com
on 15 Oct 2010 at 6:36
Hi,
What is your use case? Do you have an application, and as part of the
application you want to drop a column (let's say to upgrade the schema to the
next version of the application)? If yes why don't you just drop the constraint
as well?
Regards,
Thomas
Original comment by thomas.t...@gmail.com
on 28 Jan 2011 at 7:44
Yes I'm trying to drop a column on the schema upgrade. As I mentioned in the
original report though I don't know the name of the constraint, H2 has given it
a name such as: FK33AFF27C9848DA.
It would be useful to just drop the column.
Gary
Original comment by bennsamg...@gmail.com
on 28 Jan 2011 at 2:12
I understand, so you created the constraint without specifying the constraint
name, as in:
alter table child add foreign key(p) references parent(id);
I'm currently implementing a solution for this problem. There are other issues
with the current algorithm, for example it thinks the column is referenced in
some cases where it actually isn't.
The problem should be fixed in the next release.
However, what will still throw an exception is if the column is referenced by a
multi-column referential constraint, check constraint, or index.
Original comment by thomas.t...@gmail.com
on 29 Jan 2011 at 11:18
The changes are now committed in the trunk (but not all tests were ran so far).
Original comment by thomas.t...@gmail.com
on 29 Jan 2011 at 3:56
Fixed in version 1.3.151.
Original comment by thomas.t...@gmail.com
on 12 Feb 2011 at 2:45
Original issue reported on code.google.com by
g...@quollwriter.com
on 12 Oct 2010 at 1:29