Is the content of each datafile in the same tablespace the same in Oracle database? - oracle

On Oracle 12c, is the content of each datafile belonging to a single tablespace the same?
If yes, is it because of performance or backup purpose thus recommanding us to store each datafile on different drives?
If no then why would we create multiple datafiles for a single tablespace when we can autoextend each datafile?

No.
The idea of multiple datafiles supporting a single tablespaces is to be able to use striping. This ofcourse only makes sense if your server has multiple physical storage devices that preferably also have their own io interface.
À table will be in the tablespaces and can allocate space in all available datafiles. So the table data can be in all datafiles.
If your io system does not consist of multiple physical devices you might as well use a bigfile tablespace that just has one big datafile. In older releases this was a restore nightmare because the backup and restore was performed file by file.

Related

Reclaiming tablespace after dropping user in Oracle 10g

I am using oracle 10g. I have created two schema/user (let's assume produser for production and devuser for development) and allocate same table space let's say "prod" and both schemas/users have some data stored in same tablespace/datafile so here my problem is first, if I drop one schema/user then related tablespace will automatically cleared or not?, if not then how can we reclaim of dropped schema/user tablespace without dropping tablespace/datafile? if you have any please suggest "How"? It will be very helpful.
Thank you!
You can think of a tablespace as being synonymous with a disk partition on your PC. Lets say you bought a 500G disk and partitioned it into 300G for C: drive, and 200G for D: drive.
When you fill your C: drive with files and then delete those files, there is now plenty of room C: drive for new files but only on C: drive. Deleting files on C: drive did not mean you get to use any of that free space for D: drive.
Tablespaces are the same. Space you free up in a tablespace can be reused by other objects (new or otherwise) in that same tablespace.
If you want to give that space that you just freed up to a different tablespace (either an existing one or a new one) then this does not happen automatically. You might be able to do something like
alter database datafile '...' resize <some smaller value>
on the tablespace you just dropped objects from, which would mean it would free up space at the OS level, which would then be allocated to something else (database or otherwise). I say "might" because even if the tablespace is 99% empty, if the remaining objects are located at (say) the beginning AND end of the file, then you can't resize the file smaller than the logical high water mark of space utilised in the file.

Oracle - clean LOB files - recovering disk space

I have a friend who has a website and asked me for help.
I often use MySQL databases but never Oracle databases.
And unfortunately he has an Oracle database, so I can't find a solution.
The available disk space is slowly decreasing... I delete a lot of lines from the table but that doesn't solve his problem.
The database continues to take up disk space slowly.
I read that LOB files do not return disk space, even if you delete data.
How can I reorganize LOB files easily with a simple request?
(or/and) How can I recover disk space on Oracle?
SELECT DISTINCT VERSION FROM PRODUCT_COMPONENT_VERSION
12.1.0.1.0
The BLOB column exists within the table blocks along with data even after deletion. It is only marked as unused. You can use the following command to free up space from the BLOB table:
ALTER TABLE <YOUR_TABLE_NAME> MODIFY
LOB <LOB_COLUMN_NAME>
( SHRINK SPACE );
Now, Table must have released some space and it is now available to be used within the tablespace.
Further, you can just alter the data file and reduce the size of the data file accordingly to free up space from Disk. (Note: Space allocated to the data file will not be automatically reduced. It must be done manually)
Cheers!!

Can Oracle schema used size can be greater than tablespace used size?

In Oracle schema used size can be greater than tablespace used size ? If yes how its possible as schema is associated with tablespace ?
A schema is not "associated" with a tablespace.
A user (=schema) can have a default tablespace, but that does not necessarily mean that all tables that user owns are stored in that default tablespace. If the user has the privileges, tables can be created in other tablespaces as well.
In addition to what #a_horse_with_no_name mentioned, you need to undrstand few basics of orale as well.
Oracle Tablespace -
This is a logical structure, meaning that a tablespace is not a
physical object
A tablespace is made of 1 or more physical structures called
datafiles. A datafile is a physical file on disk, just like any other file which sits on a hard disk but in an Oracle format. The datafile is created as part of a tablespace, and only one tablespace
Each tablespace can have different characteristics, such as extent
size and how the extents are managed
They are used to group segments into logical
groups. For example, you may have accounting data in one tablespace
and reporting data in another.
The Oracle Schema or User
Oracle Schema and user are synonymous and the terms are usually used
interchangeably
There can be thousands of users within one database
The schema owns segments and objects (tables, indexes,views,
constraints, etc) and each segment/object can belong to only one
schema

oracle how to lower hwm? I want to get my filesystem space back

I want more file system space. so I truncate all tables in oracle ,but the higher water mark still so high, I shrink my tables; I had google it ,shrink only cut dowen the space higher than hwm It reduce some space, but It help less.and I find that tablespace is only used 1% space.how can I free the space in my file system.
Finally, We find that we get a droped table in the end of the segment, so the hwm is high, we purge the tablespace , then alter table datefile resize.
One way to do it is to export the database at user level using exp. Then drop and recreate the user. Then do an import. This should free up some space.
You can also use alter database datafile to reduce one of your datafiles (these are the physical files on your hard drive used by the db).
There is a great overview of how to reclaim datafile space in this article. TL DR - export, drop user, alter datafile, import.
http://oracle-base.com/articles/misc/reclaiming-unused-space.php

Database vs tablespace, what's the difference?

In oracle what's the differences between a database and a table space?
A little terminology:
Oracle defines a database as the set of files that you find on your Oracle system. This means all data in your Oracle system is in these database files, commonly known as "data files". There are other files in the database such as parameter files and redo logs.
On the other hand, an instance consists of the processes and memory areas that Oracle database uses. Together, a database and an instance make up a database system. (For more information, see the Oracle Concept guide)
Logically, you will want to define different spaces within that database. This is done via tablespaces (see Oracle Concept guide). A tablespace usually consists of one or more data files. When you define a table with CREATE TABLE, you can specify in which tablespace the table should be created. This allows you to seperate different applications on the same database system, for example.
The Oracle Concepts guide is an excellent source of information for questions like these. See this picture on how data files and tablespaces are composed.
Let's consider an example of an Ocean consist of lots of water. Now you want that water. For this what you do is collect water in barrel for better usage and better storage purpose. Same here Ocean is database having lots of Data files here data file means water and for better usage and handling you put that into barrel you can relate barrel as Tablespace
An Oracle database consists of one or more logical storage units
called tablespaces, which collectively store all of the database's
data.
Databases, tablespaces, and datafiles are closely related, but they have important differences:
Each tablespace in an Oracle database consists of one or more files
called datafiles, which are physical structures that conform to the
operating system in which Oracle is running.
A database's data is collectively stored in the datafiles that
constitute each tablespace of the database. For example, the simplest
Oracle database would have one tablespace and one datafile. Another
database can have three tablespaces, each consisting of two datafiles
(for a total of six datafiles).
reference link
DATABASES's data are stored in logical storage units called TABLESPACES. A database may contain "one or more" tablespaces. A tablespace may contain one or more datafiles.
A database's data is collectively stored in the datafiles that constitute each tablespace of the database.
Example: the simplest database may have one tablespace and one datafile. On the other hande another database can have 5 tablespaces which may contain two datafiles each (On a total of 10 files)
This question is quite dated. IBM Db2 also has Table spaces. I think there is some commonality between Db2 table spaces and Oracle database table spaces. In that respect this link offers more insight into why table spaces, as storage structures, are needed and how are they distinct from databases. Two benefits are easy recoverability of the database and better storage management.

Resources