zoukankan      html  css  js  c++  java
  • 【笔记】oracle 笔记

    --删除表并放到回收站
    drop table j1;

    --查看回收站
    SELECT * FROM recyclebin;

    --在回收站还原表
    flashback table j1 to before drop;

    --在回收站彻底删除表
    purge table j1;

    --彻底删除表
    drop table j1 purge;

    delete数据并且提交,这种情况如何恢复数据?
    1.查询数据库当前时间
    select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

    2.查询删除数据时间点之前的数据
    select * from jfltemp as of timestamp to_timestamp('2021-09-09 15:30:53','yyyy-mm-dd hh24:mi:ss');

    3.恢复数据
    flashback table jfltemp to timestamp to_timestamp('2021-09-09 15:30:53','yyyy-mm-dd hh24:mi:ss');
    如报错:ORA-08189:未启用行移动功能,不能闪回表;执行以下SQL:
    alter table jfltemp enable row movement;

    ========================================================================================
    1.增
    create table tb1 as select * from tb2 where 1=2;
    create table tb1(zd1 int,zd2 char(8),zd3 long);

    create index id_zd1 on tb1(zd1);
    insert into tb1 select * from tb2 where zd1 in (1,2,3);
    insert into tb1 (zd1,zd2) values(1,'cc');


    ========================================================================================
    2.删
    drop table tb1;

    drop index id_zd1;
    delete from tb1 where zd1=1;
    alter table tb1 drop column zd1;


    ========================================================================================
    3.改
    select a.*,rowid from tb1 a where zd1=1;
    update tb1 set zd3=2,zd2='aa' where zd1=1;
    rename tb1 to ttbb1;
    alter table tb1 add zd3 char(8);
    alter table tb1 rename column zd3 to zzdd3;
    alter table tb1 modify zd3 int;


    ========================================================================================
    4.查
    select * from tb1;
    select a.column_name,a.data_type from tab_cols a where table_name=upper('tb1');
    select * from all_users;
    select table_name from user_tables;
    select * from all_views;
    select * from user_sys_privs;

    =========================================================================================

  • 相关阅读:
    生成客户端信任的证书文件
    postgresql Streaming Replication监控与注意事项
    采用pacemaker+corosync实现postgresql双机热备、高可用方案
    51nod1305(简单逻辑)
    51nod1091(贪心)
    51nod1009(1的数目)
    51nod1102(数塔)
    51nod1459(带权值的dijkstra)
    51nod1265(判断四个点是否共面)
    51node1264(判断线段相交)
  • 原文地址:https://www.cnblogs.com/jiangfenli/p/14467921.html
Copyright © 2011-2022 走看看