[size=medium] http://blog.163.com/yuxiangtong0524@126/blog/static/800861632010827252844/?suggestedreading&wumii
1.删除表中数据两种方法
a. delete from My_Table;
b. truncate table My_Table;
2.删除整个表
drop table My_Table;
如何恢复不小心 Drop 掉的表呢,其实 Oracle 中也有类似的 "回收站"
比如不小心删除了表 My_Table
drop table My_Table;
这个时候再用SELECT语句查询此表时,将会提示表或视图不存在.
但可以用如下语句查询到这个表还在Oracle回收站中:
SELECT * FROM user_recyclebin WHERE original_name='My_Table';
那么现在就可以用如下语句进行恢复:
FLASHBACK TABLE My_Table TO BEFORE DROP;
2、oracle利用现有表创建新表
CREATE TABLE <newtable> AS SELECT {* | column(s)} FROM <oldtable> [WHERE <condition>];
exp:
SQL> CREATE TABLE yonghu_bak AS SELECT * FROM yonghul;
SQL> CREATE TABLE yonghu_bak AS SELECT id, name,sex FROM yonghu;
SQL> CREATE TABLE yonghu_bak AS SELECT * FROM yonghu WHERE 1=2;
PS:
(1)建一个新表,架构、字段属性、约束条件、数据记录跟旧表完全一样:
Create Table print_his_0013 as Select * from print_his_0007
(2)建一个新表,架构跟旧表完全一样,但没有内容:
Create Table print_his_0013 as Select * from print_his_0007 where 1=2
[/size]
1.删除表中数据两种方法
a. delete from My_Table;
b. truncate table My_Table;
2.删除整个表
drop table My_Table;
如何恢复不小心 Drop 掉的表呢,其实 Oracle 中也有类似的 "回收站"
比如不小心删除了表 My_Table
drop table My_Table;
这个时候再用SELECT语句查询此表时,将会提示表或视图不存在.
但可以用如下语句查询到这个表还在Oracle回收站中:
SELECT * FROM user_recyclebin WHERE original_name='My_Table';
那么现在就可以用如下语句进行恢复:
FLASHBACK TABLE My_Table TO BEFORE DROP;
2、oracle利用现有表创建新表
CREATE TABLE <newtable> AS SELECT {* | column(s)} FROM <oldtable> [WHERE <condition>];
exp:
SQL> CREATE TABLE yonghu_bak AS SELECT * FROM yonghul;
SQL> CREATE TABLE yonghu_bak AS SELECT id, name,sex FROM yonghu;
SQL> CREATE TABLE yonghu_bak AS SELECT * FROM yonghu WHERE 1=2;
PS:
(1)建一个新表,架构、字段属性、约束条件、数据记录跟旧表完全一样:
Create Table print_his_0013 as Select * from print_his_0007
(2)建一个新表,架构跟旧表完全一样,但没有内容:
Create Table print_his_0013 as Select * from print_his_0007 where 1=2
[/size]