Can someone look at the linked reference and explain to me the precise statements to run?
Oracle DBA’s Guide: Creating a Large Index
Here’s what I came up with…
CREATE TEMPORARY TABLESPACE ts_tmp
TEMPFILE 'E:\temp01.dbf' SIZE 10000M
REUSE AUTOEXTEND ON EXTENT MANAGEMENT LOCAL;
ALTER USER me TEMPORARY TABLESPACE ts_tmp;
CREATE UNIQUE INDEX big_table_idx ON big_table ( record_id );
DROP TABLESPACE ts_tmp;
Edit 1
After this index was created, I ran an explain plan for a simple query and get this error:
ORA-00959: tablespace 'TS_TMP' does not exist
It seems like it’s not temporary at all… 🙁
This creates a temporary tablespace (an area on disk where the intermediate sort results will be stored). An index is a sorted set of data, and sorting needs lots of space.
“Temporary” here means that the data that is stored is temporary by nature, not that the tablespace itself is temporary. Think of it like of
/tmpdirectory inUnixor%TEMP%folded inWindows: the directory / folder itself is permanent, but the data stored within it are temporary.REUSEmeans do not fail if the file already exists (usually used when the filename points to a raw device, like unformatted disk partition, to avoidOSfile management overhead). Instead, it will just open the file for writing and fill it with the new data. If not for this clause, the command would fail if the file with the given name existed.AUTOEXTEND ONmeans “grow the file if required”. If you set it to off and10Gbwill be not enough for the sorting operation, the tablespace will not automatically grow, and the operation will fail.EXTENT MANAGEMENT LOCALmeans that the tablespace layout is stored in the tablespace itself (not in the system tables). Not sure about11g, but in previous versions ofOraclethis option was not available for temporary tablespaces.This makes the user
meto use the newly created temp tablespace as a temporary storage mediumThis just creates the index.
This drops the temporary tablespace.
Before running the script, figure out the current default tablespace:
Most probably, it will return
TEMP.Before dropping
ts_tmp, revert the default temp tablespace for the user: