Issue Details (XML | Word | Printable)

Key: DERBY-4016
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Kim Haase
Reporter: Kim Haase
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Document syntax change for ALTER TABLE in Reference Manual

Created: 12/Jan/09 04:38 PM   Updated: 04/May/09 06:22 PM
Component/s: Documentation
Affects Version/s: 10.5.1.1
Fix Version/s: 10.5.1.1

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works DERBY-4016.diff 2009-01-16 09:58 PM Kim Haase 2 kB
File Licensed for inclusion in ASF works DERBY-4016.diff 2009-01-16 07:06 PM Kim Haase 2 kB
HTML File Licensed for inclusion in ASF works rrefsqlj81859.html 2009-01-16 09:58 PM Kim Haase 19 kB
HTML File Licensed for inclusion in ASF works rrefsqlj81859.html 2009-01-16 07:06 PM Kim Haase 19 kB
Issue Links:
Dependants
 

Resolution Date: 21/Jan/09 07:49 PM


 Description  « Hide
DERBY-4013 adds support for the standard SET keyword in addition to the optional WITH keyword in ALTER TABLE ALTER [COLUMN] statements. This change should be documented in the Reference Manual.

Question: [WITH] DEFAULT occurs also in ALTER TABLE ADD COLUMN. Will SET work here as well?

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kim Haase added a comment - 13/Jan/09 05:11 PM
The "Derby and standards" section of the Developer's Guide (http://db.apache.org/derby/docs/dev/devguide/cdevstandards806118.html) mentions Derby's implementation of ALTER TABLE:

"ALTER TABLE syntax
    Derby uses a slightly different ALTER TABLE syntax for altering column defaults. While SQL99 uses DROP and SET, Derby uses DEFAULT."

Is our ALTER TABLE syntax now standard, since we now support both DROP and SET? Should this item be removed?

Knut Anders Hatlen added a comment - 14/Jan/09 10:29 AM
SQL allows this construct, which is still not accepted by Derby, I think:

  ALTER TABLE t ALTER COLUMN c DROP DEFAULT

Kim Haase added a comment - 14/Jan/09 06:52 PM
Thanks, Knut. I suppose we could then modify the statement to say,

"ALTER TABLE syntax
    Derby limits somewhat the ALTER TABLE syntax for altering column defaults. Derby does not support DROP DEFAULT."

Would that be correct?

I haven't yet heard back as to whether SET DEFAULT works with ALTER TABLE ADD COLUMN as well as ALTER TABLE ALTER COLUMN -- does it?

Dag H. Wanvik added a comment - 15/Jan/09 04:24 PM
As far as ADD COLUMN, that uses the normal column definition syntax.

[Section 11.13 in SQL 2003 has the production

<set column default clause> ::= SET <default clause>

which is only ever used by <alter column action>, see section 11.12.]

We still do not support the syntax for DROP DEFAULT, but one can specify SET DEFAULT NULL
which has the same semantics as dropping the default. We should probably add this syntax as well. I will
see if I can fit it into DERBY-4013.. Thanks for alerting me.


Kim Haase added a comment - 15/Jan/09 10:04 PM
Thanks, Dag. So the last line of column-alteration in http://db.apache.org/derby/docs/dev/ref/rrefsqlj81859.html will change to

  column-name [ WITH | SET ] DEFAULT default-value

(Presumably you can't use both WITH and SET?)

Currently we don't say anything about this clause, but I can add that you can specify NULL as the default-value to disable a previous default setting. Can you use NULL if you don't use SET -- that is, can you specify WITH DEFAULT NULL or just DEFAULT NULL?

Kim Haase added a comment - 16/Jan/09 07:06 PM
Attaching DERBY-4016.diff and rrefsqlj81859.html, which make what I believe are the necessary changes to the ALTER TABLE syntax along with an explanatory couple of sentences and an example. Please let me know whether anything needs changing.

Kim Haase added a comment - 16/Jan/09 09:58 PM
Having learned from a comment on DERBY-4013 that we're now implementing DROP DEFAULT, I'm filing new versions of DERBY-4016.diff and rrefsqlj81859.html that include that change, and that also move the information about the two DEFAULT clauses to a more visible place, in the section "Modifying columns". Hope this is okay.

Knut Anders Hatlen added a comment - 19/Jan/09 01:20 PM
The patch looks fine to me. You're right that we cannot use both WITH and SET. I'm not sure if DROP DEFAULT and SET DEFAULT NULL have the exact same semantics (DROP DEFAULT is supposed to fail if there is no default, I think) but the current wording, which just says that SET DEFAULT NULL is an alternative, should be OK.

Kim Haase added a comment - 21/Jan/09 07:49 PM
Thanks very much, Knut Anders.

Committed patch DERBY-4016.diff to documentation trunk at revision 736390.

Kim Haase added a comment - 23/Jan/09 05:40 PM
Closing, since the fix has appeared in the latest alpha docs.