Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Tablespaces maxsize "unlimited" not really unlimited

I recently needed to import a .dmp into a new user I created. I also created a new tablespace for the the user with the following command:

create tablespace my_tablespace
 datafile 'C:\My\Oracle\Install\DataFile01.dbf' size 10M
 autoextend on
 next 512K
 maxsize unlimited;

While the import was running I got an error:

ORA-01652 Unable to extend my_tablespace segment by in tablespace

When I examined the data files in the dba_data_files table, I observed the maxsize was around 34gb. Because I knew the general size of the database, I was able to import the .dmp without any issues after adding multiple datafiles to the tablespace.

Why did I need to add multiple datafiles to the tablespace when the first one I added was set to automatically grow to an unlimited size? Why was the maximum size 34gb and not unlimited? Is there a hard cap of 34gb?

like image 381
spots Avatar asked May 20 '15 20:05

spots


People also ask

How many tablespaces can a database have?

A tablespace belongs to only one database and has at least one datafile that is used to store data for the associated tablespace. We can also define tablespaces as logical storage units made up of one or more datafiles. One tablespace can have up to 1022 datafiles. This number also depends upon your OS.

How do I increase the maximum size of a tablespace?

To increase the tablespace size, add a new datafile. When you add a new data file, be sure that you choose the right values for AUTOEXTEND, SIZE, and MAXSIZE. These values can't be altered later.

What is unlimited tablespace privilege in Oracle?

To permit a user to use an unlimited amount of any tablespace in the database, grant the user the UNLIMITED TABLESPACE system privilege. This overrides all explicit tablespace quotas for the user. If you later revoke the privilege, then you must explicitly grant quotas to individual tablespaces.

How many tablespaces can be created in a single database?

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).


1 Answers

As you've discovered, and as Alex Poole pointed out, there are limits to an individual data file size. Smallfiles are limited to 128GB and bigfiles are limited to 128TB, depending on your block size. (But you do not want to change your block size just to increase those limits.) The size limit in the create tablespace command is only there if you want to further limit the size.

This can be a bit confusing. You probably don't care about managing files and want it to "just work". Managing database storage is always gonna be annoying, but here are some things you can do:

  1. Keep your tablespaces to a minimum. There are some rare cases where it's helpful to partition data into lots of small tablespaces. But those rare benefits are usually outnumbered by the pain you will experience managing all those objects.
  2. Get in the habit of always adding more than one data file. If you're using ASM (which I wouldn't recommend if this is a local instance), then there is almost no reason not to go "crazy" when adding datafiles. Even if you're not using ASM you should still go a little crazy. As long as you set the original size to low, you're not close to the MAX_FILES limit, and you're not dealing with one of the special tablespaces like UNDO and TEMP, there is no penalty for adding more files. Don't worry too much about allocating more potential space than your hard-drive contains. This drives some DBAs crazy, but you have to weigh the chance of running out of OS space versus the chance of running out of space in a hundred files. (In either case, your application will crash.)
  3. Set the RESUMABLE_TIMEOUT parameter. Then SQL statements will be suspended, may generate an alert, will be listed in DBA_RESUMABLE, and will wait patiently for more space. This is very useful in data warehouses.

Why is it called "UNLIMITED"?

I would guess the keyword UNLIMITED is a historical mistake. Oracle has had the same file size limitation since at least version 7, and perhaps earlier. Oracle 7 was released in 1992, when a 1GB hard drive cost $1995. Maybe every operating system at the time had a file size limitation lower than that. Perhaps it was reasonable back then to think of 128GB as "unlimited".

like image 105
Jon Heller Avatar answered Nov 02 '22 19:11

Jon Heller