oracle 在toad中怎么执行多条DDL语句
夕拾黄花 2011-08-16 09:59:52 数据库中已经有数据了,数据不能删。现在我要一次修改很多表的结构,比如修改表的字段长度或者默认值等。其中会添加或删除临时表。怎么样才能在toad中一次性执行完呢。
举个例子:
现在有这么几条语句
create table tb1(id,name,department);
alter table tb1 modify(name default '无');
alter table tb1 modify(department varchar2(32));
drop table tb2;
怎么样才能一次性执行完呢?
我曾找过方法;
查到两种就是
1
create table tb1(id,name,department);
commit;
alter table tb1 modify(name default '无');
commit;
alter table tb1 modify(department varchar2(32));
commit;
drop table tb2;
commit;
我执行了没反应
2.begin execute immediate
'create table tb1(id,name,department)';
execute immediate
'alter table tb1 modify(department varchar2(32))';
execute immediate
'alter table tb1 modify(name default null)';
execute immediate
'drop table tb2';
end;
这个是可以的 ,但是我的
'alter table tb1 modify(name default null)';
这句 里面 的default 后面是实际的值
比如
'alter table tb1 modify(name default '无')';
这么多单引号 就不行了啊。。。怎么办 ??有没有转义之类的??