oracle 如何修改列的大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39785471/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to modify the size of a column
提问by user2121
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
我在 Oracle SQL Developer 中创建了表 Test_Project2。之后我意识到列 proj_name 很小,所以我决定使用以下语句修改列
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
但出于某种原因,Oracle SQL Developer 用红色强调了分号,我不知道什么是错误以及如何纠正它
Test_Project2:
测试_项目2:
CREATE TABLE Test_Project2 (
proj_id number(30),
proj_name VARCHAR2 (30),
proj_desc VARCHAR2(300)
);
回答by sstan
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:
无论 Oracle SQL Developer 在语法突出显示中可能指出什么错误,实际上alter
完全按照最初的方式运行您的语句可以完美运行:
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));
回答by Sebz
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:
如果你运行它,它会工作,但为了让 SQL Developer 识别而不是警告可能的错误,你可以将其更改为:
ALTER TABLE TEST_PROJECT2 MODIFY (proj_name VARCHAR2(300));
回答by Cecil Ryu Martial Arts
This was done using Toad for Oracle 12.8.0.49
这是使用 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)) ;