Oracle provides "alter table" syntax to modify data columns in-place in this form:
alter table
table_name
modify
column_name datatype;
If you are brave you can use a single "alter table" syntax to modify multiple columns:
alter table
table_name
modify
(
column1_name column1_datatype,
column2_name column2_datatype,
column3_name column3_datatype,
column4_name column4_datatype
);
Here are some examples of Oracle "alter table" syntax to modify data columns and note that you can add constraints like NOT NULL:
ALTER TABLE
customer
MODIFY
(
cust_name varchar2(100) not null,
cust_hair_color varchar2(20)
)
;
ALTER TABLE t_yms_template MODIFY ( REQST_START_MOTH null);
We can also use Oracle "alter table" syntax in dynamic PL/SQL to modify data columns
BEGINSQL_STRING := 'ALTER TABLE '||:TABLE_NAME||' MODIFY '||:COLUMN_NAME||' VARCHAR2(100'; . . .
END;
本文介绍如何使用Oracle SQL的ALTER TABLE语法来修改表中的数据列类型,并展示了如何在单条命令中修改多个列以及如何添加NOT NULL等约束条件的示例。
5813

被折叠的 条评论
为什么被折叠?



