Script – Check and take tablespaces from backup mode

I have created these on Windows environment, using in unix/linux is possible, but some changes in the spool path and script call are needed.

-- Show all tablespaces in backup mode:
SELECT t.name AS "TB_NAME", b.status
FROM V$DATAFILE d, V$TABLESPACE t, V$BACKUP b
WHERE d.TS#=t.TS#
AND b.FILE#=d.FILE#
AND b.STATUS='ACTIVE';
/
-- Check and take tablespaces from backup mode
SPOOL C:\endbackup.sql
SELECT 'ALTER TABLESPACE ' || t.name || ' END BACKUP.'
FROM V$DATAFILE d, V$TABLESPACE t, V$BACKUP b
WHERE d.TS#=t.TS#
AND b.FILE#=d.FILE#
AND b.STATUS='ACTIVE';
SPOOL OFF
@C:\endbackup.sql
/
Advertisements

About Bruno Carvalho

Coffee addicted tech guy.
This entry was posted in Scripts and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s