create table Computers
(
comNo number(4) constraint pk_comp primary key,
compModel varchar2(64) constraint unique_comp unique,
buyTime date,
price number(12,2) constraint ch_price check(price>0 and price<=300000),
owner varchar2(32)
);
create or replace procedure test is --存储过程,名称为test
DECLARE
i number := 0;
BEGIN
for i in 1 .. 100 --循环从0-100
--另外一种 while i <= 100
loop
insert into computers
(comNo, compModel, buyTime, price, owner)
values
(i, '8' + i, sysdate, i, 'libai');
--续 i := i + 1 ;
end loop;
commit;
END;
insert into computers (comNo, compModel, buyTime, price, owner) values(1,2,sysdate,111,'libai');
commit;
select * from Computers ; --查询Computers信息
select * from Computers for update; --查询并修改信息
delete from Computers; --会有记录存在日志中
truncate table Computers; --不会有记录存在日志中
?
|