创建序列
create sequence WX_MATERIAL_CONTENTPIC_ID --序列名称
minvalue 1 --最小值
maxvalue 9999999999999999999999999999 --最大值
start with 1 --当前从1开始
increment by 1 --每次自增1
cache 10;
创建触发器
create or replace trigger 触发器名称 before
insert on 作用表名称 for each row /*对每一行都检测是否触发*/
begin
select seq_cfg_monitor_program.nextval into:New.id from dual;
end;
数据库备份
1、切换成oracle用户
su - oracle
2、查询当前文件夹权限
数据导入
ls -ld 文件夹路径
3、执行命令,表数据为空:rows=n
exp xt_zhsw_wx/xt0371@127.0.0.1:1521/ORCL file=D:\xt_zhsw_wx.dmp owner=xt_zhsw_wx log=20211213.log
imp xt_zhsw_wx/xt0371@ORCL file=/root/XT_ZHSW_WX.dmp log=/root/XT_ZHSW_WX.log fromuser=xt_zhsw_wx touser=xt_zhsw_wx
查询所有序列
select * from USER_SEQUENCES;
查询代表中某个字段是否重复
select
*
from
wx_pay_user
where
openid
in
(select openid from wx_pay_user a group by openid having count (openid) > 1)
过滤单个重复字段
select distinct t.openid from wx_pay_user t
时间范围查询
select distinct to_char(d.exchg_date,'yyyymmdd')
from a_order_info_chk d where d.pay_mode='0304' and d.exchg_date>=to_date('2021-12-13','yy-mm-dd')
and d.exchg_date<=to_date('2022-01-09','yy-mm-dd');
按照符号分割某个字段中数据
select openid from
(SELECT openid, --需要查询表中的的字段,唯一主键
REGEXP_SUBSTR(USERTABLES,'[^,]+', 1, LEVEL) TYPE --需要拆分的字段,直接把TYPE换成你要拆分的那个字段即可
FROM WX_PAY_USER --表名
--WHERE --id = '12359' --你如果有条件,在此处加上即可,没有的话去掉就是拆分所有的
where USERTABLES is not null
CONNECT BY LEVEL <=REGEXP_COUNT(USERTABLES, ',') + 1 --需要拆分的字段,直接把TYPE换成你要拆分的那个字段即可
AND Id= PRIOR ID --需要查询表中的的字段,唯一主键,把WID换成你表中的唯一主键即可,其他不变
AND PRIOR DBMS_RANDOM.VALUE IS NOt NULL) --这句话照抄,不要改
where type =310176