aspose file tools*
The moose likes JDBC and the fly likes Can we add null constraint to existing table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can we add null constraint to existing table" Watch "Can we add null constraint to existing table" New topic
Author

Can we add null constraint to existing table

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1223
Can we add null constraint to existing table?
Shinil Mohan
Ranch Hand

Joined: Aug 24, 2011
Posts: 37

Yes we can add null constraint to existing table.

ALTER TABLE `hibernate`.`billingdetails` CHANGE COLUMN `BANK_NAME` `BANK_NAME` VARCHAR(255) NOT NULL ;

ALTER TABLE `hibernate`.`billingdetails` CHANGE COLUMN `BANK_ACCOUNT_NO` `BANK_ACCOUNT_NO` VARCHAR(255) NULL ;
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4464
    
    8

As long as the data already in the table satisfies the constraint. If it doesn't you'll have to fix the data first.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can we add null constraint to existing table