[ 
https://issues.apache.org/jira/browse/DERBY-7121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17391376#comment-17391376
 ] 

Walter Weinmann commented on DERBY-7121:
----------------------------------------

The JDBC class DatabaseMetaData does not seem to be the problem. Rather, it 
seems to be impossible to drop a unique key with two columns.

My DDL for the database table:


{code:java}
CREATE TABLE KXN_SCHEMA.COUNTRY_STATE (
        PK_COUNTRY_STATE_ID BIGINT NOT NULL,
        FK_COUNTRY_ID BIGINT NOT NULL,
        FK_TIMEZONE_ID BIGINT NOT NULL,
        COUNTRY_STATE_MAP BLOB,
        CREATED TIMESTAMP NOT NULL,
        MODIFIED TIMESTAMP,
        NAME VARCHAR(100) NOT NULL,
        SYMBOL VARCHAR(50),
        CONSTRAINT CONSTRAINT_KXN_4 UNIQUE (),
        CONSTRAINT "SQL00000085-b0ec4122-017b-0583-e8a3-000016e126" PRIMARY KEY 
(),
        CONSTRAINT "SQL00000086-c934c123-017b-0583-e8a3-000016e126" FOREIGN KEY 
() REFERENCES KXN_SCHEMA.COUNTRY(),
        CONSTRAINT "SQL00000087-017d8124-017b-0583-e8a3-000016e126" FOREIGN KEY 
() REFERENCES KXN_SCHEMA.TIMEZONE()
);
CREATE INDEX "SQL00000086-c934c123-017b-0583-e8a3-000016e126" ON 
KXN_SCHEMA.COUNTRY_STATE (FK_COUNTRY_ID);
CREATE INDEX "SQL00000087-017d8124-017b-0583-e8a3-000016e126" ON 
KXN_SCHEMA.COUNTRY_STATE (FK_TIMEZONE_ID);
CREATE UNIQUE INDEX "SQL00000088-62a30128-017b-0583-e8a3-000016e126" ON 
KXN_SCHEMA.COUNTRY_STATE (FK_COUNTRY_ID,NAME);

{code}

My ALTER TABLE statement:


{code:java}
ALTER TABLE COUNTRY_STATE DROP UNIQUE 
"SQL00000088-62a30128-017b-0583-e8a3-000016e126"
{code}


Error message:


{code:java}
SQL Error [30000] [42Y55]: 'ALTER TABLE' cannot be performed on 'COUNTRY_STATE' 
because it does not exist.

{code}



Translated with www.DeepL.com/Translator (free version)

> DROP UNIQUE KEY not working
> ---------------------------
>
>                 Key: DERBY-7121
>                 URL: https://issues.apache.org/jira/browse/DERBY-7121
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.15.2.0
>         Environment: Own Docker Image based on Ubuntu 20.04, please see here: 
> https://hub.docker.com/repository/docker/konnexionsgmbh/apache_derby
>            Reporter: Walter Weinmann
>            Priority: Major
>         Attachments: IssueApacheDerby.pdf
>
>
> I try to drop the FOREIGN KEY, PRIMARY KEY and UNIQUE KEY constraints before 
> the INSERT. To do this, I use the DatabaseMetaData class from JDBC. When 
> dropping the UNIQUE KEY I get the following error message:
> {{java.sql.SQLSyntaxErrorException: ALTER TABLE failed. There is no 
> constraint 'KXN_SCHEMA.SQL00000166-6f554487-017a-f4fd-c9dc-000016e126' on 
> table '"KXN_SCHEMA". "COUNTRY_STATE"'.}}
> Details about the error and the database environment can be found in the 
> attached PDF document.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to