Thanks Hasanthi for the detail explanation.
Thanks, T.Nila. On Fri, Sep 8, 2017 at 6:38 PM, Hasanthi Purnima Dissanayake < [email protected]> wrote: > Hi Nilasini, > > The IBM documentations states below when we don't define any default value > after the column name [1] . > > "Omission of NOT NULL and DEFAULT from a column-definition, for a column > other than an identity column, is an implicit specification of DEFAULT > NULL. For an identity column, it is an implicit specification of NOT NULL, > and DB2 generates default values." > > So in your case as *'REMAINING_SETS' *is not a primary key column then, > if we don't define anything it will take 'Null' as the default value. But > if you don't define a default value for a primary key column, then the > default value will be NOT NULL. > > [1] https://www.ibm.com/support/knowledgecenter/en/SSEPEK_10. > 0.0/sqlref/src/tpc/db2z_sql_createtable.html > > Thanks, > > > Hasanthi Dissanayake > > Software Engineer | WSO2 > > E: [email protected] > M :0718407133| http://wso2.com <http://wso2.com/> > > On Fri, Sep 8, 2017 at 5:56 PM, Nilasini Thirunavukkarasu < > [email protected]> wrote: > >> Hi, >> >> In DB2 if we want to set default value as null for a column, do we need >> to specify it explicitly?. According to the following[1] blog we don't need >> to specify the NULL as default since it will implicitly take the default >> value as NULL if we didn't specify it. >> >> For the following script do we need to specify the default value as null >> for the column *REMAINING_SETS?* >> >> CREATE TABLE IDN_RECOVERY_DATA ( >> USER_NAME VARCHAR(255) NOT NULL, >> USER_DOMAIN VARCHAR(127) NOT NULL, >> TENANT_ID INTEGER DEFAULT -1 NOT NULL, >> CODE VARCHAR(255) NOT NULL, >> SCENARIO VARCHAR(255) NOT NULL, >> STEP VARCHAR(127) NOT NULL, >> TIME_CREATED TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, >> * REMAINING_SETS VARCHAR(2500) WITH DEFAULT NULL,* >> PRIMARY KEY(USER_NAME, USER_DOMAIN, TENANT_ID, SCENARIO,STEP), >> UNIQUE(CODE)) >> >> [1] https://www.datavail.com/blog/using-nulls-db2/ >> >> -- >> Nilasini Thirunavukkarasu >> Software Engineer - WSO2 >> >> Email : [email protected] >> Mobile : +94775241823 <+94%2077%20524%201823> >> Web : http://wso2.com/ >> >> >> <http://wso2.com/signature> >> > > -- Nilasini Thirunavukkarasu Software Engineer - WSO2 Email : [email protected] Mobile : +94775241823 Web : http://wso2.com/ <http://wso2.com/signature>
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
