Menu

#1507 ALTER TABLE .. ALTER COLUMN doesn't adhere to the documentation

version 2.4.x
closed-out-of-date
None
1
2019-06-04
2018-03-29
Lukas Eder
No

Try the following script:

CREATE TABLE x (i INT);
ALTER TABLE x ALTER COLUMN i BIGINT NOT NULL;

According to the documentation, the above should be perfectly fine
http://www.hsqldb.org/doc/guide/ch09.html#alter_table-section

The relevant section is:

This form of ALTER TABLE ALTER COLUMN accepts a columnDefinition as in a CREATE TABLE command, with the following restrictions.

Restrictions

...
The NOT NULL attribute will be that of the new definition (similar to previous item).

However, the parser rejects the query with "unexpected token: NOT in statement". The same is true when adding a DEFAULT clause and other clauses.

Discussion

  • Fred Toussi

    Fred Toussi - 2018-03-29

    The documentation you link to is for version 1.8 (see the top of the file).

    HSQLDB version 2.x documentation shows the syntax as ALTER TABLE x ALTER COLUMN i SET DATA TYPE BIGINT or SET NOT NULL

    http://hsqldb.org/doc/guide/databaseobjects-chapt.html#dbc_table_manupulation

    Although there is an undocumented compatibility feature that allows you to omit the word COLUMN

     

    Last edit: Fred Toussi 2018-04-09
    • Lukas Eder

      Lukas Eder - 2018-03-29

      I see, thanks for the clarification.

      I keep forgetting about the manual version - would be great if unversioned URLs would point to the latest version, and versioned URLs only would point to specific versions, but that's a different story :)

       
    • Lukas Eder

      Lukas Eder - 2018-03-29

      Hmm, no your suggested syntax doesn't seem to work on version 2.4.0. It appears that only a single one of these actions can be executed in a statement:

      <alter column action> ::= <set column default clause> | <drop column default clause> | <alter column data type clause> | <alter identity column specification> | <alter column nullability> | <alter column name> | <add column identity specification> | <drop column identity specification>

       

      Last edit: Lukas Eder 2018-03-29
  • Fred Toussi

    Fred Toussi - 2018-03-29

    Yes, only one action at a time is generally allowed.

     
  • Fred Toussi

    Fred Toussi - 2018-04-09
    • status: open --> closed-out-of-date
    • assigned_to: Fred Toussi
    • Priority: 5 --> 1
     

Log in to post a comment.