How to drop unnamed unique constraint

Help
toro
2014-07-08
2014-07-08
  • toro

    toro - 2014-07-08

    Hello,

    Does somebody know how I can drop an unnamed unique constraint ?

    Thanks for your help and the great job HSQLDB is.

     
  • Fred Toussi

    Fred Toussi - 2014-07-08

    Unnamed constraints are given a name by the database engine. You can check the relevant INFORMATION_SCHEMA tables to find the name of the constraint. You can then use the name to drop the constraint.

     
  • toro

    toro - 2014-07-08

    Thank you for the quick answer.

    I've found the name of the constraint (SYS_CT_10184). But I'm wondering: the same sql files defining unnamed unique constraints are used to create multiple instance of the database. Will the generated name be always the same in all the databases ?

    Another thing I remarked is that if instead of writing my database in a file, I use the in memory mode, then the ALTER TABLE mytable DROP CONSTRAINT SYS_CT_10184 fails saying that the constraint named SYS_CT_10184 does not exist.

     
  • Fred Toussi

    Fred Toussi - 2014-07-08

    The generated name can be different in different databases.

    In the second case, you must query the memory database for the actual name.

     
  • toro

    toro - 2014-07-08

    Do you mean that to delete this unnamed unique constraint, my only solution is to drop the table defining it (after having copied its content for example) ?

     
  • Fred Toussi

    Fred Toussi - 2014-07-08

    No. You can write a program to query the INFORMATION_SCHEMA table and find the constraint name from the table name and column names. The name is then used to construct an SQL statement to DROP the constraint.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks