This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes Can we add null constraint to existing table Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply 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

sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
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: 3791
    
    1

As long as the data already in the table satisfies the constraint. If it doesn't you'll have to fix the data first.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel/download
 
subject: Can we add null constraint to existing table
 
Similar Threads
Identify not null columns
Create primary and foreign key with SQL
Hibernate and database data modifications
To identify Primary Keys in a table
Check Constraints