Oracle应用基础sql语句,执行多条,误删回复,序列,表锁……
------ 1、添加序列 --------
create sequence SEQ_YJ_USERID.Nextval
minvalue 10000000
maxvalue 99999999
start with 10000000
increment by 1
nocache;
------ 2、查询序列 ------
select SEQ_YJ_USERID.nextval from dual
------ 3、del 误删回复 ------
insert into 表名(select * from 表名as of timestamp to_timestamp('2017-12-21 17:00:00','yyyy-mm-dd hh24:mi:ss'));
-- 执行多条sql
begin
update 表名 set seq = 1, vessel_id = 'Jin14', vessel_type = 'TRACK' where id= '20837';
update 表名 set seq = 2, vessel_id = 'Jin14', vessel_type = 'TRACK' where id= '20992';
end;
------ 4、查看表锁 ------
SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username,
l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time
FROM v$locked_object l, all_objects o, v$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid
ORDER BY sid, s.serial# ;
------ 5、解锁 ------
ALTER system KILL session 'SID,serial#'