Amrmsmb
Amrmsmb

Reputation: 1

how to modify the size of a column

I created the table Test_Project2 in Oracle SQL Developer. After that I realized that the column proj_name is of a small size, so I decided to modify the column using the follwoing statement

ALTER TABLE TEST_PROJECT2 MODIFY proj_name VARCHAR2(300);

but for some reason Oracle SQL Developer underscores the semi-colon with red and I do not what is mistake and how to correct it

Test_Project2:

CREATE TABLE Test_Project2 (
proj_id number(30),
proj_name VARCHAR2 (30),
proj_desc VARCHAR2(300)
);

Upvotes: 92

Views: 456625

Answers (3)

Cecil Ryu Martial Arts
Cecil Ryu Martial Arts

Reputation: 141

This was done using Toad for Oracle 12.8.0.49

ALTER TABLE SCHEMA.TABLENAME 
    MODIFY (COLUMNNAME NEWDATATYPE(LENGTH)) ;

For example,

ALTER TABLE PAYROLL.EMPLOYEES 
    MODIFY (JOBTITLE VARCHAR2(12)) ;

Upvotes: 14

sstan
sstan

Reputation: 36483

Regardless of what error Oracle SQL Developer may indicate in the syntax highlighting, actually running your alter statement exactly the way you originally had it works perfectly:

ALTER TABLE TEST_PROJECT2 MODIFY proj_name VARCHAR2(300);

You only need to add parenthesis if you need to alter more than one column at once, such as:

ALTER TABLE TEST_PROJECT2 MODIFY (proj_name VARCHAR2(400), proj_desc VARCHAR2(400));

Upvotes: 162

Sebz
Sebz

Reputation: 502

If you run it, it will work, but in order for SQL Developer to recognize and not warn about a possible error you can change it as:

ALTER TABLE TEST_PROJECT2 MODIFY (proj_name VARCHAR2(300));

Upvotes: 15

Related Questions