(一)修改表列
语法:alter table [schema_name.]table_name
{
add column_name data_type [column_attributes] |
drop column column_name |
modify column_name data_type [column_attributes]
}
1 新增表列
alter table invoice_check add invoice_name varchar2(200);
2 修改表列
alter table invoice_check MODIFY invoice_name varchar2(100) CHECK(LENGTH(invoice_name) <= 50);
3 删除表列
alter table invoice_check DROP COLUMN invoice_name;
4 重命名表列
alter table invoice_check RENAME COLUMN invoice_name TO invoice_name_short;
(二) 修改约束
语法:alter table table_name
{
add constraint constraint_name constraint_definition [DISABLE] |
drop constraint constraint_name |
enable [novalidate] constraint_name |
DISABLE constraint_name
}
1 添加约束
alter table invoice_check ADD CONSTRAINT invoice_check_pk PRIMARY KEY (invoice_id);
2 删除约束
alter table invoice_check DROP CONSTRAINT invoice_check_pk;
3 启用/ 禁用 约束
alter table invoice_check ENABLE CONSTRAINT invoice_check_pk;
alter table invoice_check DISABLE CONSTRAINT invoice_check_pk;