ORACLE 语句技巧
来源:互联网 发布:dns端口 53 953 编辑:程序博客网 时间:2024/05/16 18:00
DECLARE
v_ename VARCHAR2(32);
CURSOR c_emp IS select table_name from dba_all_tables t where t.owner='SUNXF';
BEGIN
OPEN c_emp;
LOOP
FETCH c_emp INTO v_ename;
EXIT WHEN c_emp%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('Salary of Employee'|| v_ename);
if v_ename!=UPPER(v_ename) then
execute immediate 'rename "'||v_ename||'" to '||UPPER(v_ename);
end if;
END LOOP;
end;
--------去重复
DELETE FROM BM E WHERE E.ROWID > (SELECT MIN(X.ROWID)
FROM BM X
WHERE X.mobile = E.mobile)
-------删除指定行
DELETE FROM BM
WHERE mobile IN (select mobile from (SELECT *
FROM (SELECT mobile, ROWNUM rn
FROM BM)
WHERE rn not BETWEEN 0 AND 4000))
-------------------------日期函数
select (sysdate-to_date( to_char(insertdate,'yyyy-mm-dd hh24:mi:ss'), 'yyyy-mm-dd hh24:mi:ss '))*24*60*60
from TB_ABC_Log;
------------存在就更新 不存在就插入
using gm g -- 关联表
on (g.mobile = f.mobile and g.content=f.content) --关联条件
when matched then --匹配关联条件,作更新处理
update set
f.Send_Times=f.Send_Times+1
when not matched then --不匹配关联条件,作插入处理。如果只是作更新,下面的语句可以省略。
insert values( g.ID,g.CODE,g.NO,g.NUM,g.MOBILE,g.CONTENT,g.SENDTIME,g.RECVTIME,
g.SEQNO,g.WAYTIME,g.MSGID,g.NUMBER,
g.SENDSTATUS,g.FILENO,g.IP,g.ISSEND,0);
select wm_concat(column_name) from user_tab_cols where table_name='NEW_USER_BILL'
-----时间间隔等待函数,等待2秒
DBMS_LOCK.sleep(2);
--------通过dblink 查询两个库 不同的字段
select 'alter table ' || table_name || ' modify ' || column_name || ' ' ||
data_type || '(' || data_length || ');'
from user_tab_cols
where table_name || column_name || data_type || data_length || nullable not in
(select table_name || column_name || data_type || data_length ||
nullable
from user_tab_cols@TEST
where table_name like 'ABC_%')
and table_name like 'ABC_%';
---------产生种子id,类似于mysql的自增长id
create or replace trigger TR_DTPROPERTIES
before insert on DTPROPERTIES for each row
begin
select to_char(DTPROPERTIES_SEQUENCE.nextval) into :new.id from dual;
end TR_DTPROPERTIES;
- ORACLE 语句技巧
- oracle数据库sql语句技巧
- Oracle SQL语句优化技巧
- SQL语句优化技巧--Oracle
- SQL语句技巧记录(Oracle + MySQL)
- oracle常用SQL语句和一些技巧
- Oracle Sql 语句优化技巧总结一
- Oracle百万记录sql语句优化技巧
- ORACLE百万记录SQL语句优化技巧
- Oracle百万记录sql语句优化技巧
- Oracle百万记录sql语句优化技巧
- ORACLE百万记录SQL语句优化技巧
- ORACLE百万记录SQL语句优化技巧
- ORACLE百万记录SQL语句优化技巧
- Oracle技巧:用v$session_longops跟踪DDL语句
- Oracle SQL语句优化技术:解读实战技巧
- Oracle百万记录sql语句优化技巧【转】
- oracle语句
- Apache安装配置ModSecurity
- ORACLE 创建分区表
- android获取图片和视频的缩略图
- InstallShield制作软件安装包:在安装过程中启动一个c#写的程序
- mongodb客户端编程
- ORACLE 语句技巧
- Spring Nested exception: Invalid byte 3 of 3-byte UTF-8 sequence
- std::vector删除重复元素和查找
- Windows平台上编译安装ACE
- printk()的使用说明
- mysql的order by,group by和distinct优化
- Steps for install libnfc in Ubuntu:
- UVa 10842 Traffic Flow(最大生成树)
- 女程序员的职业规划