SQL> show user
USER is "SCOTT"
SQL> create table tt2(id int,dt date,datec varchar2(20));
Table created.
SQL> edit
Wrote file afiedt.buf
1 begin
2 for i in 1..1000 loop
3 insert into tt2 values(i,sysdate,to_char(sysdate,'yyyymmddHH24miss'));
4 dbms_lock.sleep(1); sleep一秒.
5 commit;
6 end loop;
7* end;
SQL> /
dbms_lock.sleep(1);
*
ERROR at line 4:
ORA-06550: line 4, column 1:
PLS-00201: identifier 'DBMS_LOCK' must be declared
ORA-06550: line 4, column 1:
PL/SQL: Statement ignored
上面提示没有权限,
SQL> conn / as sysdba
Connected.
SQL> show user
USER is "SYS"
SQL> grant execute on dbms_lock to scott; 赋予scott的dbms_lock的执行权限。
Grant succeeded.
重新执行。
SQL> begin
2 for i in 1..1000 loop
3 insert into tt2 values(i,sysdate,to_char(sysdate,'yyyymmddHH24miss'));
4 dbms_lock.sleep(1);
5 commit;
6 end loop;
7 end;
8 /
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24237320/viewspace-1813862/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/24237320/viewspace-1813862/