Home Database Mysql Tutorial ORACLE 回收站当前状态查询整理

ORACLE 回收站当前状态查询整理

Jun 07, 2016 pm 05:56 PM
recycle bin

回收站(Recycle Bin)从原理上来说就是一个数据字典表,放置用户删除(drop)掉的数据库对象信息,接下来详细介绍下ORACLE 回收站方方面面感兴趣的你可以参考下哈

回收站(Recycle Bin)从原理上来说就是一个数据字典表,放置用户删除(drop)掉的数据库对象信息。用户进行删除操作的对象并没有被数据库删除,仍然会占用空间。除非是由于用户手工进行Purge或者因为存储空间不够而被数据库清掉。

在Oracle 10g数据库中,引入了一个回收站(Recycle Bin)的数据库对象。
回收站,顾名思义,它就是存储被删掉的东西。从原理上来说就是一个数据字典表,放置用户删除(drop)掉的数据库对象信息。用户进行删除操作的对象并没有被数据库删除,仍然会占用空间。除非是由于用户手工进行Purge或者因为存储空间不够而被数据库清掉。数据库有了这样的功能,能够减少很多不必要的麻烦。
如果一个表被删除,那么与该表有关联的对象,例如索引、约束和其他依赖对象都会在前面加bin$$这个前缀。

启动和关闭
你可以使用下面的查询语句来查看回收站的当前状态:

1.SELECT Value FROM V$parameter WHERE Name = 'recyclebin';
如果返回值为“on”表明回收站是启动的,“off”表明是关闭的。
当然,你可以启动或者关闭回收站里的每个会话(session)和系统(system),代码如下:
代码如下:
ALTER SYSTEM SET recyclebin = ON;
ALTER SESSION SET recyclebin = ON;
ALTER SYSTEM SET recyclebin = OFF;
ALTER SESSION SET recyclebin = OFF;

获取回收站里的内容
你可以使用下面的任意一个语句来获得回收站中的对象:
代码如下:
SELECT * FROM RECYCLEBIN;
SELECT * FROM USER_RECYCLEBIN;
SELECT * FROM DBA_RECYCLEBIN;

还原
可以使用如下语法来还原被删除的对象:
代码如下:
FLASHBACK TABLE > TO BEFORE DROP RENAME TO >;

备注:这里的RENAME是给删除的对象进行重新命名,是一个可选命令。
清空回收站
这里的清空包含两种情况,第一你可以有条件的清空;第二是全部清空。我们先来看看有条件的清空该如何做:
a.清空一个特定的表:
代码如下:
PURGE TABLE >;

b.清空一个特定的索引:
代码如下:
PURGE INDEX >;

c.清空与该表空间有关联的对象:
代码如下:
PURGE TABLESPACE>;

d.清空一个特定用户的表空间对象:
代码如下:
PURGE TABLESPACE> USER >;

e.清空回收站:
代码如下:
PURGE RECYCLEBIN;

f.当一个表被删除(drop)时就直接从回收站中清空
代码如下:
DROP TABLE > PURGE;

Demo
1.启动回收站功能
代码如下:
ALTER SYSTEM SET recyclebin = ON;

2.创建一个DEMO_RECYCLEBIN表
代码如下:
CREATE TABLE DEMO_RECYCLEBIN (COL1 NUMBER);

3.向DEMO_RECYCLEBIN表中插入一条数据
代码如下:
INSERT INTO DEMO_RECYCLEBIN (COL1) VALUES (1); COMMIT;

4.删除(Drop)DEMO_RECYCLEBIN表
代码如下:
DROP TABLE DEMO_RECYCLEBIN;

5.查询
代码如下:
SELECT * FROM USER_RECYCLEBIN;

结果:
6.从回收站中还原DEMO_RECYCLEBIN表
代码如下:
FLASHBACK TABLE DEMO_RECYCLEBIN TO BEFORE DROP;

7.还原后查询
代码如下:
SELECT * FROM DEMO_RECYCLEBIN;

查询结果和删除前是一致的。
8.删除表,并且将其从回收站中清空
代码如下:
DROP TABLE DEMO_RECYCLEBIN PURGE;
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Recover expired and deleted Microsoft Teams meeting recordings in 4 easy steps Recover expired and deleted Microsoft Teams meeting recordings in 4 easy steps Sep 01, 2023 pm 08:37 PM

How to recover expired and deleted Microsoft Teams meeting recordings in 4 steps? Well, it's easy to do and should take no more than 3 minutes. But first things first: Whenever you record a Microsoft Teams meeting, the recording will automatically be in two places: On the user's OneDrive account – the user who started the recording. On a SharePoint site – if the meeting is held in a channel. If a recording is accidentally deleted, it will go to the Recycle Bin, where it will remain there for 90 days - a Microsoft policy to ensure the space is properly optimized over time. You can simply restore it from there. How to restore

How to pin the recycle bin icon to the taskbar in Debian11 Xfce? How to pin the recycle bin icon to the taskbar in Debian11 Xfce? Dec 27, 2023 pm 07:41 PM

How to add the Recycle Bin to the taskbar in Debian11Xfce? The Recycle Bin can be set to be displayed on the taskbar. How to do this? Let’s take a look at the detailed error adding. . Click [All Apps] - [Settings] - [Panel]. Click the [Project] tab and click [Add]. Find [Recycle Bin] in the [Add New Item] window and click [Add] again. Then click the Recycle Bin icon on the taskbar to open the Recycle Bin.

How to delete desktop recycle bin in ubuntu17.10 How to delete desktop recycle bin in ubuntu17.10 Jan 05, 2024 am 08:30 AM

I like my computer desktop to be clean and concise, but I found that there is a Recycle Bin on the desktop of Ubuntu 17.10. I want to delete it. How to delete it? Let’s take a look at the detailed tutorial below. 1. First, we right-click on the desktop and "Open Terminal". 2. Then you need to update the resources, otherwise the software resources may not be found. $sudoapt-getupdate3. Install the tweak tool, which is used to configure desktop optimization. $sudoapt-getinstallgnome-tweak-tool4. After installation, directly "gnome-tweak-tool" opens this optimization tool in the terminal. 5. Switch to &l on the left

How to recover accidentally deleted files in the Recycle Bin of QQ Browser How to recover accidentally deleted files in the Recycle Bin of QQ Browser Jan 30, 2024 pm 02:48 PM

How does QQ Browser recover accidentally deleted files through the Recycle Bin? If we accidentally delete a file in QQ browser, we can directly retrieve it in the recycle bin. When we use QQ browser, we will download some files. Unnecessary files will also be deleted regularly. However, some friends have accidentally deleted the files they need, and they can be retrieved directly in the Recycle Bin. The editor below has compiled a tutorial on how to recover accidentally deleted files through the recycle bin in QQ browsing. If you are interested, follow me and read on! QQ Browsing Tutorial on recovering accidentally deleted files through the recycle bin 1. Open the latest QQ browser on your mobile phone, and click the "File" item in the navigation bar at the bottom of the browser, as shown in the figure. 2. At this time, you will enter the file management page of the mobile QQ browser. Click on the upper right corner of the page.

How to easily change Recycle Bin settings on Windows 11 How to easily change Recycle Bin settings on Windows 11 Sep 22, 2023 pm 01:25 PM

For most people, the Recycle Bin is simply a storage for deleted files that can be recovered later or permanently deleted. What you may not realize is that you can configure it and decide what happens when files are deleted from your computer. Given how easy it is to change these settings, you should be able to adjust them in no time and enjoy the new look, efficiency, and customization of your Recycle Bin. Why do I need to manage my recycle bin settings? If you're not careful, the Recycle Bin can fill up with files that you don't need to keep permanently but want to keep just in case. That's why you need to decide what happens to these files instead of letting them hang. Additionally, you may end up with a slower computer with unnecessary files taking up valuable space on your hard drive. better one

Win10 only displays the desktop of the Recycle Bin when booting Win10 only displays the desktop of the Recycle Bin when booting Dec 31, 2023 am 09:57 AM

When many users turn on the computer, they find that only the Recycle Bin is left on the desktop, and other desktop icons have disappeared. Don’t panic at this time. It may be that your shortcut keys have deleted the desktop icons. At this time, we can restore the desktop icons in the Recycle Bin. That’s it, or you can click to personalize the desktop icon. Let’s take a look at the specific steps. Method for recovering desktop icons with only the Recycle Bin left: 1. If there is only one Recycle Bin left on the desktop, it is possible that you have deleted all the shortcut keys for changing sides. At this time, you can click on the Recycle Bin to see if you can find a shortcut to delete it. 2. If you see the shortcuts you deleted, select all the shortcuts, right-click the mouse and select Restore. 3. You can also right-click the mouse and click Undelete. So fast

Does the Recycle Bin take up memory space? Does the Recycle Bin take up memory space? Apr 12, 2021 pm 04:27 PM

The recycle bin does not occupy memory space, but only hard disk space; because the memory is a place where data is temporarily stored when running a program, and the data in the memory disappears when the computer is turned off, while the hard disk is a place where data is permanently stored, as long as it is not deleted manually. The data will not be deleted automatically, so the Recycle Bin should be emptied regularly to free up hard disk space.

Introducing the enhancement of the recycle bin function of CentOS system Introducing the enhancement of the recycle bin function of CentOS system Jan 03, 2024 pm 07:22 PM

After linuxrm deletes a file, it is more troublesome to restore it. Even if it is restored, the file name format becomes a string of numbers. Modify the root user's environment variable vi~/.bashrc comment line 5 alias #aliasrm='rm-i' and add the following content to the last line mkdir-p~/.trashaliasrm=trashaliasr=trashaliasrl='ls~/.trash'aliasur =undelfileundelfile(){mv-i~/.trash/$@./}trash(){mv$@~/.trash/}cleartrash(){read-p"c

See all articles