Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java DB (Derby) Database Alter Column Size

I'm trying to alter the size of a field in my Java DB Database. I just can't seem to do it. My current data type is varchar(50) and I want to update it to varchar(150).

like image 814
Josh Pritchard Avatar asked Dec 22 '25 05:12

Josh Pritchard


2 Answers

Solved:

ALTER TABLE [table] ALTER COLUMN [column] SET DATA TYPE [type];

I wasn't using the SET DATA TYPE function and was instead just trying to redeclare it by using ALTER COLUMN [column] [type];

like image 105
Josh Pritchard Avatar answered Dec 23 '25 19:12

Josh Pritchard


For mysql you can do this way

alter table table_name modify col_name varchar(150)

JDBC codes

PreparedStatement pt =connection.prepareStatement("alter table table_name modify col_name varchar(150)");
pt.executeUpdate();

In ms sql server use this command

ALTER TABLE [table_name]
ALTER COLUMN [Column_name] varchar(150)
like image 22
SpringLearner Avatar answered Dec 23 '25 17:12

SpringLearner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!