Oracle determine tablespace name from id - oracle

Oracle 11.2.0.3.0
I am trying to create a graph with historical database size information. The table dba_hist_tbspc_space_usage is clearly the one to use however as shown in this link this table has a TABLESPACE_ID.
Can someone tell me how to find a mapping between tablespace_id and tablespace_name? I tried querying in all_tablespaces but there is no id. However I can see that it is somehow the #rownum (?)
Is there a correct way to find the mapping?

Tablespace Id is present in v$tablespace view (TS# column).
You can refer more about it from oracle documentation
Cheers!!

Related

Sequence in create table?

So I failed in exam with score 60% which needed 3% for pass, and I want to know about sequence in create table statement, in question given us that =>
in the database "exist" sequence for example SEQ_001 and used in for example=>
SQL>create table ( id number default seq_001.nextval ); or
create table ( id number default seq_001.currval );
And in the topic of 1z0 071 written that =>
This exam was validated against 11g Release 2 version 11.2.0.1.0 and up to 19c
And I know that sequence is possible in create table from 12c but not in previous versions, so how I can know that which version is for this questions and how to check that the exist sequence is used with nextval, exists not means that it is used( I am about nextval after creating, if no currval can give error ). In this type questions I confused.
The following statement
create table t23 ( id number default seq_001.nextval );
succeeds on Oracle 18c (demo on db<>fiddle).
but fails on Oracle 11gR2 with this error:
ORA-00984: column not allowed here
db<>fiddle uses XE editions, but I don't think that's the explanation. So it seems the exam was not "was validated against 11g Release 2 version 11.2.0.1.0" with full rigour.
Regarding the question of Oracle versions for taking the 1z0-071 exam I would say that although there are differences between 11g up to 19c, most of the questions should be based on concepts that are standard between these versions.
More specifically for the Sequence part of the question, although it is possible to create a table with a default value pointing to currval, it would seldom be useful. Using the example of ID above, imagine using this sequence to create user IDs. We would expect different users to have different IDs, and with currval there is a strong possibility that different users would have the same ID making the column essentially useless.
Although not specified in your question, I would assume that most examples of using a sequence default would be for a surrogate primary key, which would need to be unique. Nextval would ensure that these would be unique assuming that rows are not entered with values greater than the existing sequence currval by an outside user.

Purging Oracle Unified Audit Trail doesn't cleanup lob data

I'm experiencing rapid growth in my SYSAUX scheme. I have found that the majority of the space (27Gb) is being consumed by a LOBSEGMENT object in the AUDSYS schema. The research I did, suggested that the Unified Audit Log needed to be purged and I went ahead and cleaned it up as it was really massive, however, space has not been released from the LOBSEGEMENT and I'm wondering if there is a way to do this?
DB Version: Oracle Database 12c Release 12.1.0.1.0 - 64bit Production
I used the below to identify large objects in the system
select s.owner, s.segment_name, s.segment_type, s.tablespace_name, sum(s.BYTES) /1024/1024/1024 SIZE_GB
from DBA_SEGMENTS s
group by s.owner, s.segment_name, s.segment_type, s.tablespace_name;
From there I identified the table name associated with the largest segment with the below:
select * from dba_lobs where SEGMENT_NAME='SYS_LOB0000019764C00014$$';
The LOG_PIECE column of the AUDSYS.CLI_SWP$ea27aff$1$1 table was identified, but I cannot query the table directly. even connected with sysdba, when I try and query the table to find out what is in it, I get "ORA-00942: table or view does not exist". I also cannot find any reference to the table or column in any other views, procedures, synonyms, etc in the DB. So I have no idea how to view the contents of the table in order to figure out what it is.
When I look at the Unified Audit Trail, I can't find anything that would link to this column either.
After purging I did another backup of the system in the hopes that it might release unused space, space is still being used and the purge did not clean it up.
Any ideas on 1. How to figure out what is in the table/column and 2. how to clean it up would really be appreciated as I'm at a bit of a loss here.

oracle dba_identifiers missing data

I have full rights on the dba_identifiers table and am trying to link this to dba_procedures and dba_arguments (yes l, I know don't use dba tables). My question is that one user's package identifier information is missing from the dba_identifiers table. It has permission on the dba_identifiers table but I think that isn't the issue.
Does anybody know whether, this dba_identifiers table doesn't always capture system metadata for packages. I am using this to try to identify whether an object is a function/procedure/type etc
To get information into DBA_IDENTIFIERS, the object must be compiled with the correct settings.
Try:
alter session set plscope_settings = 'identifiers:all'
alter package my_schema.my_package compile;
And then look in DBA_IDENTIFIERS for the missing information.

Partition setup in oracle

We are having few tables with partitions and we don't know how to get the partition keys for a specific table.
How can I get or view the partition key set up in oracle database for a specific table?
You'll find that information here:
select * from USER_PART_TABLES;
select * from USER_PART_KEY_COLUMNS;
Source.
Check out all the below data dictionary views,
ALL_PART_KEY_COLUMNS
DBA_PART_KEY_COLUMNS
USER_PART_KEY_COLUMNS
There is also a view called ALL_SUBPART_KEY_COLUMNS.

Selection of table (or view) in oracle, that I cannot find in TOAD

I am reverse-engineering an application which administers an Oracle database.
Everything is new to me (application + database)
There is a statement there somewhere, which is:
SELECT * FROM XXX#YYY (XXX is a word, YYY another word)
If I go into my database with TOAD I can't find an 'XXX#YYY' table nor view. If I copy paste the statement in TOAD's editor, I get results as if the table exists.
I know that the '#' symbol is allowed for naming an Oracle object. Is it possible that it means something else here though?
How can I find the table (or view)? Is it possible to get information through a statement such as which schema does 'XXX#YYY' belong to or weather it is a table or a view, so that I can track it?
The database consists of many schemas. There is a default one. Is it possible that XXX#YYY may belong to another schema, rather than the default?
Please help me find the table.
Identifier behind # is database link. It is a way to access objects on some remote Oracle server. more info on http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_5005.htm#SQLRF01205
In Toad/Oracle XXX#YYY means object#database_link.
Look for the schema in your DB, there you will find the table.
Btw: I think its better to use SCHEMA.TABLENAME
If you have problems finding the SCHEMA, go to View->Toad Options, select Treeview at Browser style and then it should display all schemas.

Resources