Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-4011

ALTER COLUMN is only allowed to change default value of some types of generated columns

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 10.5.1.1
    • None
    • SQL
    • Normal

    Description

      ALTER TABLE ... ALTER COLUMN is allowed to change the default of columns that are GENERATED ALWAYS AS IDENTITY, but it's not allowed to change the default of columns that are GENERATED ALWAYS AS (expression). It would be good if it had the same behaviour for all generated columns.

      ij> create table t1(x int generated always as (-1));
      0 rows inserted/updated/deleted
      ij> alter table t1 alter column x default 22;
      ERROR 42XA7: 'X' is a generated column. You cannot change its default value.
      ij> create table t2(x int generated always as identity);
      0 rows inserted/updated/deleted
      ij> alter table t2 alter column x default 22;
      0 rows inserted/updated/deleted
      ij> insert into t2 values default;
      1 row inserted/updated/deleted
      ij> select * from t2;
      X
      -----------
      22

      1 row selected

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              knutanders Knut Anders Hatlen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: