Board index » delphi » Interbase - Can't add primary key to table

Interbase - Can't add primary key to table

I have tried without success to add a primary key constraint to an empty
table called Authors. This is my SQL (executed in WISQL Delphi Developer
2.0) query :

        Alter table Authors
        add constraint Author_ID primary key

        When I run this, I get SQLCode -104 "Unexpected end of command".
        I have tried several variations (hit return key to next line,
finishing with ';' character) with no success.
        Any ideas for this Sybase-aware, Delphi-newbie hack ?

                                                Serge M.

 

Re:Interbase - Can't add primary key to table


Quote
s3035...@mpce.mq.edu.au (MERZLIAKOV Serge) wrote:
> I have tried without success to add a primary key constraint to an empty
> table called Authors. This is my SQL (executed in WISQL Delphi Developer
> 2.0) query :

>    Alter table Authors
>    add constraint Author_ID primary key

>    When I run this, I get SQLCode -104 "Unexpected end of command".

That's right, the command is not properly ended. I bet that Author_ID
is your column-name :-). Correct syntax is:

Alter table Authors
add constraint Author_ID primary key (ColumnName [, ColumnName [,.]])

so in your case, and if my assumption is right, that will be:
        alter table authors
        add constraint authors_pk primary key ( author_id )
but beware: this will fail if author_id is nullable...

Good luck!

Jasper

PS: please take into consideration
- when replying, I just think I know;
- when asking, be sure that I don't.

Other Threads