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

Allow standard SQL syntax: ALTER TABLE ALTER [COLUMN] <col> SET DEFAULT <default>

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 10.0.2.0, 10.0.2.1, 10.1.1.0, 10.1.2.1, 10.1.3.1, 10.2.1.6, 10.2.2.0, 10.3.1.4, 10.3.2.1, 10.3.3.0, 10.4.1.3, 10.4.2.0
    • Fix Version/s: 10.5.1.1
    • Component/s: SQL
    • Labels:
      None

      Description

      Presently, the Derby syntax is ALTER TABLE ALTER [COLUMN] <col> [WITH] DEFAULT <default>.
      The "SET" keyword is not accepted, only an optional "WITH". It would be good to accept the standard syntax here as well.
      Cf. SQL 2003, section 11.12 <alter column definition> and section 11.13 <set column default clause>.

      Also, DROP DEFAULT is standard syntax not supported, so we should add that, too.

      Repro on trunk:

      $ java org.apache.derby.tools.ij
      ij version 10.5
      ij> connect 'jdbc:derby:wombat;create=true';
      ij> create table t(i int default 0, j int);
      0 rows inserted/updated/deleted
      ij> alter table t alter column j with default 1;
      0 rows inserted/updated/deleted
      ij> insert into t values (default, default);
      1 row inserted/updated/deleted
      ij> select * from t;
      I |J
      -----------------------
      0 |1

      1 row selected
      ij> alter table t alter column j default 2;
      0 rows inserted/updated/deleted
      ij> insert into t values (default, default);
      1 row inserted/updated/deleted
      ij> select * from t;
      I |J
      -----------------------
      0 |1
      0 |2

      2 rows selected
      ij> alter table t alter column j set default 3;
      ERROR 42X01: Syntax error: Encountered "set" at line 1, column 30.

        Attachments

        1. derby-4013.diff
          5 kB
          Dag H. Wanvik
        2. derby-4013.stat
          0.2 kB
          Dag H. Wanvik
        3. derby-4013b.diff
          6 kB
          Dag H. Wanvik
        4. derby-4013b.stat
          0.2 kB
          Dag H. Wanvik
        5. derby-4013c.diff
          7 kB
          Dag H. Wanvik
        6. derby-4013c.stat
          0.2 kB
          Dag H. Wanvik
        7. derby-4013d.diff
          8 kB
          Dag H. Wanvik
        8. derby-4013d.stat
          0.2 kB
          Dag H. Wanvik

          Issue Links

            Activity

              People

              • Assignee:
                dagw Dag H. Wanvik
                Reporter:
                dagw Dag H. Wanvik
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: