Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
Database Tools
SQL Scripts & Samples
» Database Forum
» Slideshows
» Sitemap
Free Newsletters:
News Via RSS Feed

follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles

SQL Scripts & Samples

Posted Nov 5, 2003

Assign temporary tablespace to database users

By Staff

>>Script Language and Platform: Oracle
This script assigns a temporary tablespace (by number of assigned users) with a database user when its temporary tablespace is wrongly associated to system tablespace or another permanent tablespace.

Author: Luis Claudio Rodrigues da Silveira

set echo off
set newpage 0
set space 0
set pagesize 0
set feed off
set head off
set trimspool on

spool change_temp_tbs.sql

select 'ALTER USER ' || a.username ||
' TEMPORARY TABLESPACE ' || a.temporary_tablespace || ';'
from dba_users a,
(select c.tablespace_name, 
from dba_users u, 
(select t.tablespace_name,
count(*) nusers
from dba_tablespaces t,
dba_users u
where t.contents = 'TEMPORARY'
and t.tablespace_name = u.temporary_tablespace
group by t.tablespace_name) c
where c.tablespace_name = u.temporary_tablespace
group by c.tablespace_name) b
where a.temporary_tablespace in
(select tablespace_name 
from dba_tablespaces
where contents <> 'TEMPORARY')
and a.temporary_tablespace = b.tablespace_name;

spool off

Disclaimer: We hope that the information on these script pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, or fitness for a particular purpose... Disclaimer Continued

Back to Database Journal Home

SQL Scripts & Samples Archives

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Latest Forum Threads
SQL Scripts & Samples Forum
Topic By Replies Updated
sql help!! add 1 August 22nd, 11:58 AM
How To Combine These 2 Queries into 1 Query ? tarek_land 1 June 7th, 08:37 AM
solving query svibuk 1 February 3rd, 06:08 AM
converting from a character string to uniqueidentifier saturnius 4 January 4th, 05:56 AM