常用Sql@TOC
oracle 数据库操作
– oracle 创建序列
create sequence table_seq increment by 1 start with 0;
– 序列的下一个值
select table_seq.nextval from dual;
– 删除序列
drop sequence table_seq;
– 修改序列
alter sequence table_seq increment by 2 maxvalue 40 cycle;
–使用alter table创建外键
alter table tb_products add constraint fk_products_supplier foreign key (supplier_id,supplier_name) references tb_supplier(supplier_id,supplier_name);
– 数据 恢复
ALTER TABLE T_DELIV_ORDER ENABLE row movement ;
flashback table T_DELIV_ORDER to timestamp to_timestamp(‘2018-11-22 15:40:00’,‘yyyy-mm-dd hh24:mi:ss’);
– 删除重复 数据
DELETE FROM T_SALE_OFFICE WHERE ( code ) IN ( SELECT code FROM T_SALE_OFFICE GROUP BY code HAVING COUNT( code ) > 1 )
AND ROWID NOT IN ( SELECT MIN( ROWID ) FROM T_SALE_OFFICE GROUP BY code HAVING COUNT( * ) > 1 );