create or replace procedure fuck
is--此处少了is或as
--begin--声明变量要出现在begin end块前
--declare --存储过程中不用declare
v_exists number;
begin--
select count(*) into v_exists from user_tables where table_name = 'TEST1';
if v_exists > 0 then
execute immediate 'drop table TEST1';
end if;
-- end;
-- begin
execute immediate '
create table test1(
mobile_id varchar2(12),
callin_time date,
callout_time date,
status char(1)
)';
--commit;--创建表属ddl语句,不需要commit;
--end;
insert into test1(mobile_id,callin_time,callout_time,
status)
select * from Call_book_info;
commit;
delete from Call_book_info where mobile_id
not in (select min(mobile_id) from call_book_info);
end;
/
exec fuck;
--或
begin
fuck;
end;
create or replace procedure fuck
is
--变量声明;
begin
--过程主体;
end fuck;
2. 如果存储过程代码无误,可以通过 "/" 来执行代码,编译存储过程。
3.通过exec 或 execute 来调用编译后的存储过程。
delete from Call_book_info where mobile_id
not in (select min(mobile_id) from call_book_info);
删除了重复的记录.
我的思路是这样想的.
望请教.
----挖坟挖到的。。 你用后边的select min(mobile_id) from call_book_info查看下有多少条记录?没错就1条!这句话的意思是把其他的都删除,只留一条ID最小的...我擦,好狠啊