Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add synthetic DDL syntax for dropping an unnamed FOREIGN KEY #9440

Open
lukaseder opened this issue Oct 25, 2019 · 0 comments

Comments

@lukaseder
Copy link
Member

@lukaseder lukaseder commented Oct 25, 2019

In SQL, it is possible to create unnamed constraints:

create table t (i int primary key); 
create table u (i int references t);

Some dialects (e.g. MySQL) support dropping unnamed primary keys using:

alter table t drop primary key;

Others (e.g. Oracle, see #9382) support dropping unnamed unique keys using:

alter table x drop unique (a, b);

It would be useful to be able to drop unnamed foreign keys as well:

alter table u drop foreign key (i) referencing t;

We would have to repeat at least:

  • The fact that it is a foreign key
  • The column list from the referencing table
  • The referenced table
  • If the referenced key is a non-primary unique constraint, then we also need a column list from the referenced table

So far, I have not seen this being supported by any dialect. We can emulate it by either:

  • Querying the dictionary views and dropping whatever constraint we find matching the criteria (default)
  • Querying our up-to-date Meta model and dropping the constraint by name, if we have the name (this is a strategic new feature, which might evolve in the future).
@lukaseder lukaseder added this to the Version 3.13.0 milestone Oct 25, 2019
@lukaseder lukaseder added this to To do in 3.13 DDL interpretation via automation Oct 25, 2019
@lukaseder lukaseder self-assigned this Oct 29, 2019
@lukaseder lukaseder referenced this issue Nov 11, 2019
0 of 7 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.