【笔记】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;

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

 

上一篇:MySQL 学习笔记3——增删改查、连表


下一篇:SQLServer获取插入记录的主键值的四种方式与测试比较