Point 5 is the reason, one of the databases I use does not handle no
definition and requires a NULL or NOT NULL definition. But its been a
long time since I checked this so the newer version may be more
compliant. I'll check before I waste any more time on this.
Interestingly derby is the first database I have encountered(I think)
that throws an error on a NULL definition.
Thanks
Bernt M. Johnsen wrote:
> I can't see any reason why anyone would spend time on this issue.
>
> 1) "NULL" is not a constraint. All columns are nullable by default
> (SQL standard and in all SQL databases to my knowledge).
>
> 2) It will not add any new functionality.
>
> 3) You will not gain anything in speed, resource usage etc.
>
> 4) By removing the "NULL constraint" from your create statements, they
> will work with Derby and be portable back to the database that
> allowed them (if it is a reasonable implementation of SQL).
>
> 5) The SQL standard does not allow this syntax, so by incorporating it
> into Derby we run the risk that some uses it and creates SQL
> statements that are not portable to other databases.
>
> So, I wonder: Why bother?
>
> Duncan Groenewald wrote:
>
>> Thanks - is there any documentation on how the parser works and
>> explaining what is the sqlgrammer.jj file is and how is it used, etc.
>>
>> Duncan
>>
>> Bryan Pendleton wrote:
>>
>>> Duncan Groenewald wrote:
>>>
>>>> Any chance someone can explain how I could modify the parser (or
>>>> whatever) to be able to handle the NULL constraint ?
>>>>
>>> Beware: I haven't tried this, but you could have a look at
>>> java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj and
>>> experimentally try to modify it for yourself.
>>>
>>> In terms of the modifications, I think you'll want to look at the
>>> subroutine columnConstraint(), and observe how the explicitNotNull
>>> and explicitNull flags are handled.
>>>
>>> Notice that there is an explicit parser block for
>>>
>>> <NOT> <NULL>
>>>
>>> I think you'll either want to add a second explicit parser block for
>>>
>>> <NULL>
>>>
>>> or modify the existing one to
>>>
>>> [<NOT>] <NULL>
>>>
>>> and either way you want to make sure that you manage the explicitNull
>>> and explicitNotNull flags properly, and that you call setNullability()
>>> on the dataTypeDescriptor to record the user's NULL / NOT NULL choice.
>>>
>>> Hope this helps,
>>>
>>> bryan
>>>
>>>
>>>
>>>
>
>
>
|