Oracle DB: Can one db file be shared between table space - oracle

Can one db file be shared between table space ?
I am deleting temp table space as below,
1)Get all the files in table
space :: SELECT FILE_NAME FROM DBA_TEMP_FILES WHERE TABLESPACE_NAME =
'TEMPRM_TEMP';
2)Drop all the files in the table space :: ALTER
TABLESPACE TEMPRM_TEMP DROP TEMPFILE
'/tmp/TEMPRM/create/TEMPRM/datafile/o1_mf_temprm_t_bw3yo9lv_.tmp';
3)Drop the actual table space :: DROP TABLESPACE TEMPRM_TEMP INCLUDING
CONTENTS AND DATAFILES;
Are there any harm with this procedure ?

is this the only temp tablespace in your database? if the answer is yes, then you will not be able to drop it. If anyone is connected to the tablespace, you will not be able to drop it. If this is not the only temp tablespace, and noone is connected to it, then it will work and is safe.

Ok here we go oracle doc
A tablespace in an Oracle database consists of one or more physical datafiles. A datafile can be associated with only one tablespace and only one database.

Related

Table space dropped but dbf file still exist

we have dropped a tablespace by command drop tablespace T1 assuming that the datafile will also be dropped. Later we created the same tablespace T1 with different datafile.
Now the problem is that datafile is holding 14GB of diskspace. Is there any way to recover that space from the datafile. Please suggest.
Thanks in advance.
take a look here
https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_9004.htm
you needed to drop the datafile at the same time as dropping the tablespace
DROP TABLESPACE tablespace INCLUDING CONTENTS AND DATAFILES CASCADE CONTRAINTS;
if you check DBA_DATA_FILES, if your old datafile is not listed you will be ok to remove it from the OS

Oracle tablespace can I drop all files

I am trying drop the temp tables space it has three files
/tmp/TEMPRM/create/TEMPRM/datafile/o1_mf_temprm_t_bw3t4zkp_.tmp
+TEMPDATA/rm/datafile/temprm_tempfile_1.dbf
+TEMPDATA/rm/datafile/temprm_tempfile_2.dbf
Before dropping table space I want to delete all the file, I am able to remove the first two files last one gives the error.
SQL> SQL> ALTER TABLESPACE TEMPRM_TEMP DROP TEMPFILE '+TEMPDATA/rm/datafile/temprm_tempfile_2.dbf'
*
ERROR at line 1:
ORA-03261: the tablespace TEMPRM_TEMP has only one file
If it is not allowed to delete all the files in table space, How to clean the table space?
You cannot make a tablespace file-less. You can however drop a tablespace and it's datafiles in one statement:
DROP TABLESPACE temp_tablespace including contents and datafiles;
Make sure that you have a new temporary tablespace and make it the default before you drop the old one. Follow the below link for an example:
http://dbatricksworld.com/how-to-create-temporary-tablespace-and-drop-existing-temprary-tablespace-in-oracle-11g/
create a new temp tablespace, make this the default for the users. Once there are no connections using the old temp tablespace you should be able to drop the old temp tablespace

ORA-01652 - Query doen't work with hibernate but it works fine in SQL client

I execute a SQL query with hibernate and the application give the error:
ORA-01652: unable to extend temp segment
The TABLE SPACE has 4 GB.
The strange thing is that the query from the application yesterday was working fine, and today it doen't work.
I have not made any changes either in the database or application.
The oracle version is Oracle 11g
You are running short on space in temp tablespace , use this query t check how much space you have in your temp tablespace
SQL> select file_name,SUM(bytes)/1024/1024 "Current_size_mb", sum(maxbytes)/1024/1024 "max_size_mb" from dba_temp_files group by file_name;
FILE_NAME Current_size_mb max_size_mb
---------------------------------------------------------------------- --------------- -----------
C:\AKS\AKDB\ORADATA\RESEARCH\TEMP01.DBF 20 32767.9844
Adding a new tempfile to temp tablespace
SQL> alter tablespace temp add tempfile 'C:\AKS\AKDB\ORADATA\RESEARCH\TEMP02.DBF' size 100m autoextend on maxsize 1g;
Temporary tablespace called TEMP which is used internally by database for operations like distinct, joins,etc to fetch large amount of data.
So, after increasing the size of TEMP tablespace the issue can be resolved.
Follow this link : How to shrink temp tablespace in oracle?

Release unused space of USERS tablespace in oracle

I have lots of table with lots of records in oracle 11g. (more than 2 billions) After applying some queries and creating some indexes I am so close to insufficient disk space. Right now for executing each query ORA-01652 error for USERS tablespace appears. I cannot add more datafile to USERS tablespace anymore because of insufficient disk space. I am sure that there are lots of unused space available on this tablespace that is not usable somehow. (I deleted some tables and indexes nothing happened) My question is how can I release this space? Thank you very much.
I don't know if you can to it for an entire tablespace but for a single table the command is:
ALTER TABLE MY_TABLE ENABLE ROW MOVEMENT; -- By defaut ROW MOVEMENT is disabled when you create a table.
ALTER TABLE MY_TABLE SHRINK SPACE CASCADE;
ALTER TABLE MY_TABLE DEALLOCATE UNUSED;
Maybe you have to loop over ALL_TABLES in your schema.
Then you can gain disc space by rebuilding your indexes.
ALTER INDEX THE_INDEX REBUILD;

Oracle Database: How can I alter a partitioned table to a new table space for not only the partitions but also the table itself?

How can I alter a partitioned table (in Oracle 10g Database) to a new table space for not only the partitions but also the table itself? Which I mean is, I can do following without issues,
--sql
alter table abc move partition abc01 tablespace new_tablespace;
alter table abc move partition abc02 tablespace new_tablespace;
alter table abc move partition abc03 tablespace new_tablespace;
but somehow the table's definition is still associating with the old table space, and and I have moved all tables data off the old table space. If I query the dba_segment for the old table space, there is nothing there. My question is, may I drop the old table space, even no data in the data files in the old table space, but somehow those partitioned tables definitions still associating with the old table space?
Each partition must be moved, as you've discovered. If you want new partitions to be created in a different tablespace without specifying that new tablespace, you'd have to use the following:
alter table abc modify default attributes tablespace new_tablespace;

Resources