Increasing size of varchar type using ALTER TABLE can implicitly change the 
column from NOT NULL to NULLable.
-------------------------------------------------------------------------------------------------------------

         Key: DERBY-882
         URL: http://issues.apache.org/jira/browse/DERBY-882
     Project: Derby
        Type: Bug
  Components: SQL  
    Versions: 10.1.2.2, 10.2.0.0    
 Environment: generic
    Reporter: Satheesh Bandaram
     Fix For: 10.2.0.0, 10.1.3.0


Altering size of a varchar column using ALTER TABLE command can change the 
column from not nullable to nullable.

ij version 10.1
ij> connect 'jdbc:derby:bdb;create=true';
ij> create table a (id integer not null, name varchar(20) not null, primary 
key(name));
0 rows inserted/updated/deleted
ij> insert into a values (1, 'abc');
1 row inserted/updated/deleted
ij> insert into a values (2, null);
ERROR 23502: Column 'NAME'  cannot accept a NULL value.                     
<==== Initially doesn't accept nulls
ij> alter table a alter name set data type varchar(50);                         
              <==== Change size of varchar column
0 rows inserted/updated/deleted
ij> insert into a values (3, 'hijk');
1 row inserted/updated/deleted
ij> insert into a values (4, null);                                             
                                <==== Now NULLs are accepted
1 row inserted/updated/deleted
ij> select * from a;
ID         |NAME
--------------------------------------------------------------
1          |abc
3          |hijk
4          |NULL


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to