您的位置:首页 > 数据库 > Oracle

oracle修改表结构(alter table),多列/多字段

2017-12-07 09:56 363 查看
--创建测试表
create table test(
id int;
);

-- 一个关键字,括号包含,逗号隔开,重命名列一次只能一列

--添加多列
alter table test add (c1 int, c2 int);  -- 正确
alter table test add column (c1 int, c2 int);   --错误,标识符无效
alter table test add columns (c1 int, c2 int);  --错误,无效的数据类型
alter table test add c1 int, add c2 int; -- 错误,无效的alter table选项

--修改多列
alter table test modify (c1 int, c2 int);   -- 正确
alter table test rename column c1 to c2;    -- 正确

--删除多列
alter table test drop (c1,c2);  --正确
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  oracle