Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a tablespace with multiple datafiles?

Tags:

oracle

I'm using the following script to create a new tablespace with three datafile with 4 MB size for each.

create tablespace homeworkts 
       datafile 'D:\oradata\orcl\df1.dbf' size 4m , 
       datafile 'D:\oradata\orcl\df2.dbf' size 4m,
       datafile 'D:\oradata\orcl\df3.dbf' size 4m;

But it keeps giving me the error

invalid file name

for the second datafile.

Why?

like image 416
Lisa Avatar asked Dec 13 '11 21:12

Lisa


People also ask

How many datafiles can a tablespace have?

A bigfile tablespace contains only one datafile or tempfile, which can contain up to approximately 4 billion ( 232 ) blocks. The maximum size of the single datafile or tempfile is 128 terabytes (TB) for a tablespace with 32K blocks and 32TB for a tablespace with 8K blocks.

Can there be more than one datafile per tablespace?

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. Oracle creates a datafile for a tablespace by allocating the specified amount of disk space plus the overhead required for the file header.

How many datafiles can be created in a single tablespace?

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.

How do I add datafiles to tablespace?

To add datafiles to a tablespace, use either the Add Datafile dialog box of Enterprise Manager/GUI, or the SQL command ALTER TABLESPACE. You must have the ALTER TABLESPACE system privilege to add datafiles to a tablespace.


1 Answers

Reading create tablespace syntax you should write:

create tablespace homeworkts 
datafile 'D:\oradata\orcl\df1.dbf' size 4m, 
         'D:\oradata\orcl\df2.dbf' size 4m, 
         'D:\oradata\orcl\df3.dbf' size 4m;

You should write datafile just for once, then all your file specification separated by commas:

enter image description here

Edited on 2018' Still valid for current create tablespace on release 18 oracle version.

like image 192
dani herrera Avatar answered Oct 12 '22 23:10

dani herrera