What is TBS when talking about databases? - sql

What does mean abbreviation "TBS" in Oracle database? .
Thanks!

TaBleSpaces
Each table is stored in a segment. Segments are stored in tablespaces. Each segment is allocated in units of "extents" which are allocated in database "blocks".
tablespace -> segment -> extent -> block
You can explicity define tablespaces. You can select which tablespace a table's segment is created in at CREATE TABLE time.

Have a look at
Oracle Concepts - Tablespaces

TBS generally refers to TableSpaces in oracle.....

Related

ORA-01652 error when fetching from cursor

I have a stored procedure where I use a cursor to loop through items in a temporary table:
OPEN CURSOR_SCORE_ITEMS FOR SELECT
ID_X, ID_Y
FROM
SCORE_ITEMS
GROUP BY
ID_X, ID_Y
HAVING
SUM(SCORE) > 10;
LOOP
FETCH CURSOR_SCORE_ITEMS BULK COLLECT INTO COMPARE_ITEMS LIMIT 100;
---loop over items and do stuff---
END LOOP;
CLOSE CURSOR_SCORE_ITEMS;
The procedure is working fine for instances where the 'SCORE_ITEMS' table is small, but for large tables (several millions of rows) I am receiving error
"ORA-01652: Temp-Segment kann nicht um 12800 in Tablespace TEMP_ALL
erweitert werden"
(sorry, its in German).
Note that SCORE_ITEMS is a temporary table which is generated earlier in the procedure. It seems that the cursor query is exceeding the size of the temp tablespace.
I read some solutions already that involve increasing the size of the tablespace but I do not have any privileges on this database so I do not think that is possible. Is there an alternative way, or some kind of preprocessing I might consider, that reduce the overhead in the temp tablespace?
Global Temporary Tables are written to TEMPORARY tablespace (that is, not the usual tablespace for heap tables). Do you have a separate temporary tablespace for GTTs? I suspect not. Most places don't.
So (assuming No), when SCORE_ITEMS has millions of rows you've already eaten a big chunk of TEMP. Then your query kicks off with an aggregation that is big enough to spill into TEMP - because GROUP BY needs sorting.
You have already ruled out the obvious solution:
increasing the size of the tablespace but I do not have any privileges on this database so I do not think that is possible.
I don't know whether this also rules out the radical idea of talking to your DBA and seeing whether they will increase the space allocated to TEMP, or - better - create a new tablespace for Global Temporary Tables.
The other thing to consider is whether you actually need TEMP_SCORE. It's not unusual for people to populate a GTT when they could just write a more efficient SELECT instead. There's a lot of overhead in a GTT - all that I/O to disk, not to mention contending for shared TEMP tablespace. It's definitely an option to consider.

using index tablespace?

I came across two code snippets :
one...
ALTER TABLE table_name
DROP CONSTRAINT constraint_name;
DROP INDEX index_name;
alter TABLE table_name ADD CONSTRAINT constraint_name PRIMARY KEY (column, column)
USING INDEX TABLESPACE tablespace_name;
Two ...
CREATE INDEX index_name ON table_name (column_name)
TABLESPACE tablespace_name;
Now I can understand the statements that are not in bold but the statements in bold are quite difficult to understand. Why are we using tablespaces, especially in this context? What is the meaning of these two statements? Can someone give me a detailed answer with examples?
Thank you!
A tablespace is a logical storage unit. Actual OS storage is defined in datafiles, and datafiles are linked to a tablespace. This means that we can deploy database objects on different servers, different OS even, without needing to know the underlying directory structure.
As for index tablespaces, indexes are physical objects and need to be stored somewhere. These days it is not as common to distinguish between Index tablespaces and table tablespaces, because modern servers are raided, striped, etc so nobody need worry about disk heads.
In fact, Oracle's built-in tablespace management is so good that we can largely forget about tablespace planning altogether. There is still a case for having separate tablespaces for e.g. read-only data, transportable tablespaces, partitioning, etc.

Create a temporary table in temporary tablespace db2

Is there a way to create a system The table was not created because the table space "TEMPTB" following the clause "IN" is a "SYSTEM TEMPORARY" table space. SQLSTATE=42838
This is the error I keep getting when I create a temp table in a temp tablespace...does db2 not support it? because oracle does.
Thanks
System Temporary tablespaces are used only for system-created temporary objects – for joins, sorts that are too large for the sort heap, table queues that overflow, etc.
You need to create a USER TEMPORARY tablespace. You can read more about the various types of tablespaces. And use the CREATE TABLESPACE command to create one.

Tablespace after Create Table. What does it mean?

Im reading some Oracle scripts, and I found one with this
Create Table XXY(...)
Tablespace SOME_TABLESPACE
....
NOCOMPRESS
NOPARALLEL
..
What does this mean? What is if for? There are many CreateTable statemsnts, but the Tablespace statement after is exactly the same.
As I understand SOME_TABLESPACE must exist when this script is excecuted, but thats all I could get. Is the purpose of the statement to store all the tables in the same place?
EDIT
I read this
http://www.adp-gmbh.ch/ora/concepts/tablespaces.html
"Same place" doesn't quite describe it ...
A tablespace is a grouping of common data files. With your "Create" statements you can define in which tablespace an object gets stored. Usually different types of oracle objects are stored in different tablespaces that can have different capabilities.
Some examples:
"Data" (your tables and the rows stored in these tables) are stored in a different tablespace than "system information" (such as transaction logs or "caches"). This allows you to store system information on a local drive (quick, but somewhat limited in space) and data in a Storage Area network (basically unlimited space, but not quite as fast).
Table Data and Indexes can be stored in different tablespaces which may be on different disks. Therefore, table lookup and index lookup can use different disks and be faster than if both were on the same disk.
Tablespaces and their different characteristics are oen of the many ways of tuning an Oracle DB. Lots of capabilities, lots of complexity. If all you're doing is a little development machine, there is little need to worry about it.
It creates the table in that tablespace. In the case of partitioned tables it defines that tablespace as the default for new partitions and subpartitions also.
Please read:
http://download.oracle.com/docs/cd/B10501_01/server.920/a96524/c04space.htm

What Does This Oracle SQL Statement Do?

I am migrating a MSSQL script to Oracle SQL and I can't figure out what one line in the script is doing.
I am very new to SQL.
CREATE TABLE HA_BACKUP_PROCESSES
(
ID numeric (10, 0) NOT NULL ,
PROCESS_ID numeric (10, 0) NOT NULL ,
BACKUP_PROCESS_ID numeric (10, 0) NOT NULL ,
CONSTRAINT HA_BCK_PROC_PK PRIMARY KEY (ID)
USING INDEX TABLESPACE userdata001
)
In the above code, what is the 'USING INDEX TABLESPACE userdata001' statement doing?
This clause allows selection of the tablespace in which the index associated with a UNIQUE or PRIMARY KEY constraint will be created. If not specified, default_tablespace is used, or the database's default tablespace if default_tablespace is an empty string
Tablespaces are nothing more than logical containers for datafiles and indexes.
When setting up an Oracle instance, you must define your tablespaces before you can create datafiles. Then, when you create a table or index you must specify the tablespace you want to create the datafile in, or accept the default tablespace.
It instructs the database to store index information in the tablespace named "userdata001".
A helpful explanation can be found here:
A tablespace is a logical storage unit within an Oracle database. It is logical because a tablespace is not visible in the file system of the machine on which the database resides. A tablespace, in turn, consists of at least one datafile which, in turn, are physically located in the file system of the server. Btw, a datafile belongs to exactly one tablespace.
Each table, index and so on that is stored in an Oracle database belongs to a tablespace. The tablespace builds the bridge between the Oracle database and the filesystem in which the table's or index' data is stored.