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 Mark Thornton <mt...@optrak.co.uk> on 2007/08/16 12:32:42 UTC
Alter table add constraints
The syntax in the documentation
(http://db.apache.org/derby/docs/dev/ref/rrefsqlj81859.html) implies
that you can add more than one constraint in a single alter table
statement, as in this example
ALTER TABLE APP.ACTIVEVEHICLES
ADD CONSTRAINT FK__ACTIVEVEH__VEHIC__7A3223E8 FOREIGN KEY (VEHICLEID)
REFERENCES APP.BASEVEHICLES (VEHICLEID) ON DELETE CASCADE
ADD CONSTRAINT FK_ACTIVEVEHICLES_SOLUTIONS FOREIGN KEY (SOLUTIONID)
REFERENCES APP.SOLUTIONS (SOLUTIONID) ON DELETE CASCADE
This results in this exception:
java.sql.SQLSyntaxErrorException: Syntax error: Encountered "ADD" at
line 4, column 1.
SQL-92 only allowed one alteration per alter table statement, I don't
have a copy of later standards.
Regards,
Mark Thornton
Re: Alter table add constraints
Posted by Mark Thornton <mt...@optrak.co.uk>.
Dag H. Wanvik wrote:
> Mark Thornton <mt...@optrak.co.uk> writes:
>
>
>> The syntax in the documentation
>> (http://db.apache.org/derby/docs/dev/ref/rrefsqlj81859.html) implies
>> that you can add more than one constraint in a single alter table
>>
>
> Does it? If a syntactic element can be repeated, there will be an
> asterisk trailing it. Braces is merely used for grouping. What part of
> the docs are you referring to?
>
>
Ah, I had assumed the braces implied repetition. Thanks.
Mark Thornton
Re: Alter table add constraints
Posted by "Dag H. Wanvik" <Da...@Sun.COM>.
Mark Thornton <mt...@optrak.co.uk> writes:
> The syntax in the documentation
> (http://db.apache.org/derby/docs/dev/ref/rrefsqlj81859.html) implies
> that you can add more than one constraint in a single alter table
Does it? If a syntactic element can be repeated, there will be an
asterisk trailing it. Braces is merely used for grouping. What part of
the docs are you referring to?
> statement, as in this example
>
> ALTER TABLE APP.ACTIVEVEHICLES
> ADD CONSTRAINT FK__ACTIVEVEH__VEHIC__7A3223E8 FOREIGN KEY (VEHICLEID)
> REFERENCES APP.BASEVEHICLES (VEHICLEID) ON DELETE CASCADE
> ADD CONSTRAINT FK_ACTIVEVEHICLES_SOLUTIONS FOREIGN KEY (SOLUTIONID)
> REFERENCES APP.SOLUTIONS (SOLUTIONID) ON DELETE CASCADE
>
> This results in this exception:
>
> java.sql.SQLSyntaxErrorException: Syntax error: Encountered "ADD" at
> line 4, column 1.
>
> SQL-92 only allowed one alteration per alter table statement, I don't
> have a copy of later standards.
This is true for SQL 2003 as well.
Thanks,
Dag
>
> Regards,
> Mark Thornton