---字串轉日期
select to_date('2011-11-30 18:00:00', 'yyyy-mm-dd hh24:mi:ss') from dual;
--select * from scott.dept d where e.deptno=d.deptno and d.deptno=10;
select sysdate, add_months(sysdate, 12) from dual;
--時間和數字直接加減
select sysdate+6/24/60,sysdate from dual;--目前時間加上6分鐘
--樣本:用於and子句中的時間加減
select r.replytime,c.sendtime,c.sendtime+6/24/60
from prplsmsreply r, prplsmscontent c
where r.parentid = c.id
and r.replytime < c.sendtime+6/24/60;--here
--加法
select sysdate,add_months(sysdate,12) from dual; --加1年
select sysdate,add_months(sysdate,1) from dual; --加1月
select sysdate,to_char(sysdate+7,'yyyy-mm-dd HH24:MI:SS') from dual; --加1星期
select sysdate,to_char(sysdate+1,'yyyy-mm-dd HH24:MI:SS') from dual; --加1天
select sysdate,to_char(sysdate+1/24,'yyyy-mm-dd HH24:MI:SS') from dual; --加1小時
select sysdate,to_char(sysdate+1/24/60,'yyyy-mm-dd HH24:MI:SS') from dual; --加1分鐘
select sysdate,to_char(sysdate+1/24/60/60,'yyyy-mm-dd HH24:MI:SS') from dual; --加1秒
--減法
select sysdate,add_months(sysdate,-12) from dual; --減1年
select sysdate,add_months(sysdate,-1) from dual; --減1月
select sysdate,to_char(sysdate-7,'yyyy-mm-dd HH24:MI:SS') from dual; --減1星期
select sysdate,to_char(sysdate-1,'yyyy-mm-dd HH24:MI:SS') from dual; --減1天
select sysdate,to_char(sysdate-1/24,'yyyy-mm-dd HH24:MI:SS') from dual; --減1小時
select sysdate,to_char(sysdate-1/24/60,'yyyy-mm-dd HH24:MI:SS') from dual; --減1分鐘
select sysdate,to_char(sysdate-1/24/60/60,'yyyy-mm-dd HH24:MI:SS') from dual; --減1秒
--begin:增加SEQ_PRPDBANKOUTLETS
drop sequence SEQ_PRPDBANKOUTLETS_test;
create sequence SEQ_PRPDBANKOUTLETS_test
increment by 1
start with 100001
maxvalue 999999999999999999999999999
minvalue 1
cache 20;
--end:增加SEQ_PRPDBANKOUTLETS
--增加欄位begin
alter table PrpLBankAccount_test add lossType char(2) not null;
--增加欄位end
--添加欄位備忘
comment on column PrpLaccountModify_test.PayObjectCode_test is '支付對象代碼';
--添加欄位備忘
--添加表備忘
comment on table PrpLaccountModify_test is '收付帳號修改申請表';
--添加表備忘
--增加索引
create index idx_cmainsub_mainno_test on prpcmainsub_test (mainpolicyno );
--刪除索引
drop index idx_cmainsub_mainno_test;
--修改欄位
alter table PrpLaccountModify_test modify lossType CHAR(2) not null;
--修改資料(update)
update Prpdcode_test a set a.codecname = '全車盜搶' where a.codetype='DamageCode' and a.codecode='815';
--增加(單行形式)
--user_objects
select * from user_objects where object_name=upper('prpdbankoutlets');
--利用endtime欄位更新endtime欄位本身
update prpdcheckshift a set a.endtime = to_date(to_char(a.endtime, 'yyyy-mm-dd')||' 23:59:59','yyyy-mm-dd hh24:mi:ss');