Christian Rodriguez wrote:

Hello everyone,

I have the following problem.

1. I created a table that has a UNIQUE constraint.

something like

create table users (
 ...
 email VARCHAR(30),
 constraint email_unq UNIQUE (email)
);

2. I drop the table and try to recreate it, but it complains that the
constraint "email_unq" already exists in schema APP.

3. Then I thought about removing the entire database by removing the
entire database directory with operating system commands.

4. I still get the same errror saying the constraint doesnt exist.

So... how do I get rid of that constraint? How do I remove all
constraints if I want to start from scratch again?

Thanks!
Xtian



Hi ,
Dropping the tables should drop the constraints on it.

http://incubator.apache.org/derby/manuals/reference/sqlj28.html#DROP+TABLE+statement

I tried it and it works fine for me:

ij version 10.1
ij> connect 'jdbc:derby:testTSNEW';
ij> create table usr(user_name char(12), email varchar(30) not null, constraint email_unq UNIQUE (email));
0 rows inserted/updated/deleted
ij> select * from usr;
USER_NAME |EMAIL -------------------------------------------


0 rows selected
ij> drop table usr;
0 rows inserted/updated/deleted
ij> create table usr(user_name char(12), email varchar(30) not null, constraint email_unq UNIQUE (email));
0 rows inserted/updated/deleted
ij> insert into usr values('abc','[EMAIL PROTECTED]');


Was the table successfully dropped in your case ?. Can you check the steps you performed again?
Any stack traces in the derby.log file ?


Regards,
Rajesh






Reply via email to