You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Legolas Woodland <le...@gmail.com> on 2006/01/02 22:19:09 UTC

What is wrong with this sql script , im sure that it is ok , but derby return error.

Hi
Thank you for reading my post.
can some one please check and see what is wrong with this scripts ?
im sure that they should execute but derby return errors like :
org.apache.derby.client.am.SqlException: Constraints 
'SQL060103004635123' and 'SQL060103004635121' have the same set of 
columns, which is not allowed.


create table WEBSITES (USERID integer not null unique, WEBSITEID bigint 
not null unique, DOMAINNAME varchar(255) not null unique, DESCRIPTION 
varchar(255), PPVIEW double, PPCLICK double, PPWEEK double, totalClick 
bigint, totalView bigint, active smallint, primary key (WEBSITEID));
create table CATEGORIES (CATEGORYID integer not null unique, 
CATEGORYNAME varchar(255) not null unique, CATEGORYDESCRIPTION 
varchar(255), categorytotalClick bigint, categoryTotalView bigint, 
primary key (CATEGORYID));
create table WEBSITES_CATEGORIES (WEBSITEID bigint not null, CATEGORYID 
integer not null, primary key (WEBSITEID, CATEGORYID));
create index Index14 on WEBSITES (active);
create index Index13 on WEBSITES (DOMAINNAME);
create index Index12 on WEBSITES (WEBSITEID);
create index Index1 on WEBSITES (USERID);
create index Index12 on CATEGORIES (CATEGORYNAME);
create index Index1 on CATEGORIES (CATEGORYID);
alter table WEBSITES_CATEGORIES add constraint FK_WEBSITES_C_4649 
foreign key (CATEGORYID) references CATEGORIES;
alter table WEBSITES_CATEGORIES add constraint FK_WEBSITES_C_5733 
foreign key (WEBSITEID) references WEBSITES;

Re: What is wrong with this sql script , im sure that it is ok , but derby return error.

Posted by Thomas Dudziak <to...@gmail.com>.
On 1/3/06, Legolas Woodland <le...@gmail.com> wrote:

>  I think you missed a post about this error.
>  One of users answered the question , as he said , I should remove unique
> from field that are in PK.
>  by the way if you think i should supply more about this error then , please
> let me know the path to submit more details.

I think he was refering to the not-so-helpful error message that you
received. If the error message would say something: "primary key
column is already unique" the problem would have been apparent to you.

Tom

Re: What is wrong with this sql script , im sure that it is ok , but derby return error.

Posted by Legolas Woodland <le...@gmail.com>.
Øystein Grøvlen wrote:
>>>>>> "LW" == Legolas Woodland <le...@gmail.com> writes:
>>>>>>             
>
>     LW> Hi
>     LW> Thank you for reading my post.
>     LW> can some one please check and see what is wrong with this scripts ?
>     LW> im sure that they should execute but derby return errors like :
>     LW> org.apache.derby.client.am.SqlException:                    Constraints
>     LW> 'SQL060103004635123'  and 'SQL060103004635121'  have the  same  set of
>     LW> columns, which is not allowed.
>
> I think this is a usability issues since the error message is not very
> helpful in order to figure out what is the cause of this error.  I
> have filed a jira issue, DERBY-789, for this.
>
>   
Hi
I think you missed a post about this error.
One of users answered the question , as he said , I should remove unique 
from field that are in PK.
by the way if you think i should supply more about this error then , 
please let me know the path to submit more details.



Re: What is wrong with this sql script , im sure that it is ok , but derby return error.

Posted by Øystein Grøvlen <Oy...@Sun.COM>.
>>>>> "LW" == Legolas Woodland <le...@gmail.com> writes:

    LW> Hi
    LW> Thank you for reading my post.
    LW> can some one please check and see what is wrong with this scripts ?
    LW> im sure that they should execute but derby return errors like :
    LW> org.apache.derby.client.am.SqlException:                    Constraints
    LW> 'SQL060103004635123'  and 'SQL060103004635121'  have the  same  set of
    LW> columns, which is not allowed.

I think this is a usability issues since the error message is not very
helpful in order to figure out what is the cause of this error.  I
have filed a jira issue, DERBY-789, for this.

-- 
Øystein


Re: What is wrong with this sql script , im sure that it is ok , but derby return error.

Posted by Legolas Woodland <le...@gmail.com>.
Thomas Dudziak wrote:
> On 1/2/06, Legolas Woodland <le...@gmail.com> wrote:
>
>   
>> Thank you for reading my post.
>> can some one please check and see what is wrong with this scripts ?
>> im sure that they should execute but derby return errors like :
>> org.apache.derby.client.am.SqlException: Constraints
>> 'SQL060103004635123' and 'SQL060103004635121' have the same set of
>> columns, which is not allowed.
>>
>> create table WEBSITES (USERID integer not null unique, WEBSITEID bigint
>> not null unique, DOMAINNAME varchar(255) not null unique, DESCRIPTION
>> varchar(255), PPVIEW double, PPCLICK double, PPWEEK double, totalClick
>> bigint, totalView bigint, active smallint, primary key (WEBSITEID));
>> create table CATEGORIES (CATEGORYID integer not null unique,
>> CATEGORYNAME varchar(255) not null unique, CATEGORYDESCRIPTION
>> varchar(255), categorytotalClick bigint, categoryTotalView bigint,
>> primary key (CATEGORYID));
>>     
>
> Names like SQL060103004635123 are created by Derby for internal things
> like in this case, unique indexes for primary keys. Your problem might
> be because you specify "unique" for the columns that make up the
> primary key, but this is automatically done by the "primary key"
> constraint. Try to omit the "unique" specifier for the pk columns and
> see whether that works.
>
> Tom
>
>   


Thank you very much.
It works

Re: What is wrong with this sql script , im sure that it is ok , but derby return error.

Posted by Thomas Dudziak <to...@gmail.com>.
On 1/2/06, Legolas Woodland <le...@gmail.com> wrote:

> Thank you for reading my post.
> can some one please check and see what is wrong with this scripts ?
> im sure that they should execute but derby return errors like :
> org.apache.derby.client.am.SqlException: Constraints
> 'SQL060103004635123' and 'SQL060103004635121' have the same set of
> columns, which is not allowed.
>
> create table WEBSITES (USERID integer not null unique, WEBSITEID bigint
> not null unique, DOMAINNAME varchar(255) not null unique, DESCRIPTION
> varchar(255), PPVIEW double, PPCLICK double, PPWEEK double, totalClick
> bigint, totalView bigint, active smallint, primary key (WEBSITEID));
> create table CATEGORIES (CATEGORYID integer not null unique,
> CATEGORYNAME varchar(255) not null unique, CATEGORYDESCRIPTION
> varchar(255), categorytotalClick bigint, categoryTotalView bigint,
> primary key (CATEGORYID));

Names like SQL060103004635123 are created by Derby for internal things
like in this case, unique indexes for primary keys. Your problem might
be because you specify "unique" for the columns that make up the
primary key, but this is automatically done by the "primary key"
constraint. Try to omit the "unique" specifier for the pk columns and
see whether that works.

Tom