DBA Task Finished
DBA Task Finished
com TABLESPACE: 1)SQL> create tablespace vichu datafile '/u01/app/oracle/oradata/testdb/dat03.dbf' size 40M ;
Tablespace created.
2)SQL> alter tablespace vichu add datafile '/u01/app/oracle/oradata/testdb/dat04.dbf' size 40M; Tablespace altered. 3)SQL> create tablespace vichu1 datafile'/u01/app/oracle/oradata/testdb/dat05.dbf' size 40M extent management local uniform size 256k; Tablespace created. SQL> alter tablespace vichu offline; Tablespace altered. SQL> drop tablespace vichu including contents; Tablespace dropped. SQL> create tablespace vichu datafile '/u01/app/oracle/oradata/testdb/tst.dbf'size 40M extent management dictionary default storage (initial 1M next 1M); Tablespace created. SQL> alter tablespace vichu logging; Tablespace altered. Create Table: SQL> create table vichu (sno number(10),name varchar2(30)); Table created. SQL> insert into vichu values(1,'viswa') ; 1 row created.
1 row created.
SQL> commit 2 /
Commit complete.
SQL> rollback;
Rollback complete.
Tablespace altered.
SQL> alter tablespace vichu add datafile '/u01/app/oracle/oradata/testdb/ds.dbf'size 40M autoextend on;
Tablespace altered.
Tablespace altered.
SQL> alter tablespace vichu drop datafile '/u01/app/oracle/oradata/testdb/ds1.dbf'; Tablespace altered. SQL> alter tablespace vichu offline; Tablespace altered. SQL> alter tablespace vichu online; Tablespace altered. SQL> alter tablespace vichu offline; Tablespace altered. SQL> alter database datafile '/u01/app/oracle/oradata/testdb/ds.dbf' offline; Database altered. SQL> alter database datafile '/u01/app/oracle/oradata/testdb/ds.dbf' online; Database altered. SQL> exec dbms_space_admin.Tablespace_Migrate_FROM_Local ('VICHU'); PL/SQL procedure successfully completed. SQL> exec dbms_space_admin.Tablespace_Migrate_TO_Local('VICHU'); PL/SQL procedure successfully completed. SQL> exec dbms_space_admin.Tablespace_Migrate_TO_Local('SYSTEM'); TEMPORARY TABLESPACE : Below query is to view the properties of temporary tablespace
SQL> SELECT * FROM DATABASE_PROPERTIES where PROPERTY_NAME='DEFAULT_TEMP_TABLESPACE';
SQL> create temporary tablespace temp tempfile '/u01/app/oracle/oradata/temp01.dbf' size 40M; Tablespace created. SQL> alter temporary tablespace temp add tempfile '/u01/app/oracle/oradata/temp02.dbf' size 40M; Tablespace altered. SQL> drop tablespace temp including contents; Tablespace dropped. SQL> create temporary tablespace temp tempfile '/u01/app/oracle/oradata/testdb/temp01.dbf' size 40M extent management local uniform size 256k; Tablespace created. Hint : we cant create temporary tablespace using dictionary mgmt.
SQL> drop tablespace vichu3 including contents; Tablespace dropped. SQL> create table emp1 (no number(10),name varchar2(20)) tablespace temp; Table created. SQL> create temporary tablespace temp1 tempfile '/u01/app/oracle/oradata/viswa/temp02.dbf' size 20M; Tablespace created. SQL> alter database tempfile '/u01/app/oracle/oradata/viswa/temp02.dbf' offline; Database altered. SQL> ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/viswa/temp02.dbf' to '/u01/app/oracle/oradata/temp02.dbf'; Database altered. SQL> alter database tempfile '/u01/app/oracle/oradata/temp02.dbf' online; Database altered.
REDO LOG: alter database add logfile group 3 '/u01/app/oracle/oradata/testdb/redo3.log' size 10M; Database altered alter database add logfile group 4 ('/u01/app/oracle/oradata/testdb/redo4.log','/u01/app/oracle/oradata/testdb/re do5.log') size 10M;
Database altered.
/u01/app/oracle/oradata/testdb/redo1.log NO
ONLINE /u01/app/oracle/oradata/testdb/redo2.log NO
ONLINE /u01/app/oracle/oradata/testdb/redo3.log NO
ONLINE /u01/app/oracle/oradata/testdb/redo4.log
STATUS ----------------
System altered.
System altered.
System altered.
STATUS ---------------ACTIVE CURRENT ACTIVE ACTIVE SQL> alter database add logfile member '/u01/app/oracle/oradata/testdb/redo6.log' to group 3; Database altered. SQL> alter database drop logfile member /u01/app/oracle/oradata/testdb/redo6.log'; Sql>alter database drop logfile group 3;
SQL> conn viswa/visu Connected. SQL> select *from stud; select *from stud * ERROR at line 1: ORA-00942: table or view does not exist
SQL> select name from stud; select name from stud * ERROR at line 1: ORA-00942: table or view does not exist
SQL> conn as sysdba Enter user-name: / Connected. SQL> select *from stud;
SQL> conn as sysdba Enter user-name: / Connected. SQL> grant select on sys.stud to viswa;
Grant succeeded.
SQL> conn as sysdba; Enter user-name: / Connected. SQL> revoke select on sys.stud from viswa;
Revoke succeeded.
Privileges:
Table 18-1 System Privileges System Privilege Name Advisor Framework Privileges:All of the advisor framework privileges are part of the DBA role.
ADVISOR
Operations Authorized --
Operations Authorized as DBMS_ADVISOR and DBMS_SQLTUNE. Please refer to PL/SQL Packages and Types Reference for information on these packages.
Create, drop, select (read), load (write), and delete a SQL tuning set owned by the grantee through the DBMS_SQLTUNE package. Create, drop, select (read), load (write), and delete a SQL tuning set owned by any user through the DBMS_SQLTUNE package. Accept a SQL Profile recommended by the SQL Tuning Advisor, which is accessed through Enterprise Manager or by the DBMS_SQLTUNE package. Drop an existing SQL Profile. Alter the attributes of an existing SQL Profile. -Create clusters in the grantee's schema. Create a cluster in any schema. Behaves similarly to CREATE ANY TABLE. Alter clusters in any schema. Drop clusters in any schema. -Create any context namespace. Drop any context namespace. -Alter the database. Issue ALTER SYSTEM statements.
CLUSTERS:
CREATE CLUSTER CREATE ANY CLUSTER
CONTEXTS:
CREATE ANY CONTEXT DROP ANY CONTEXT
DATABASE:
ALTER DATABASE ALTER SYSTEM
Operations Authorized Issue AUDIT statements. -Create private database links in the grantee's schema. Create public database links. Drop public database links. -Connect the current session to a debugger. Debug all PL/SQL and Java code in any database object. Display information on all SQL statements executed by the application. Note: Granting this privilege is equivalent to granting the DEBUG object privilege on all applicable objects in the database.
DATABASE LINKS:
CREATE DATABASE LINK
DEBUGGING:
DEBUG CONNECT SESSION
DIMENSIONS:
CREATE DIMENSION
-Create dimensions in the grantee's schema. Create dimensions in any schema. Alter dimensions in any schema. Drop dimensions in any schema. -Create directory database objects. Drop directory database objects. -Create an indextype in the grantee's schema.
DIRECTORIES:
CREATE ANY DIRECTORY DROP ANY DIRECTORY
INDEXTYPES:
CREATE INDEXTYPE
Operations Authorized Create an indextype in any schema and create a comment on an indextype in any schema. Modify indextypes in any schema. Drop an indextype in any schema. Reference an indextype in any schema. -Create in any schema a domain index or an index on any table in any schema. Alter indexes in any schema. Drop indexes in any schema. The following privileges are needed to execute procedures in the DBMS_SCHEDULER package. Create jobs, schedules, or programs in the grantee's schema. Create, alter, or drop jobs, schedules, or programs in any schema. Note: This extremely powerful privilege allows the grantee to execute code as any other user. It should be granted with caution.
INDEXES:
CREATE ANY INDEX
CREATE JOB
Create in the grantee's schema an executable scheduler job that runs on the operating system. Use any program in a job in the grantee's schema. Specify any job class in a job in the grantee's schema. Create, alter, or drop any job class, window, or window group.
MANAGE SCHEDULER
Operations Authorized -Create external procedure or function libraries in the grantee's schema. Create external procedure or function libraries in any schema. Drop external procedure or function libraries in any schema. -Create a materialized view in the grantee's schema. Create materialized views in any schema. Alter materialized views in any schema. Drop materialized views in any schema. This privilege has been deprecated. No privileges are needed for a user to enable rewrite for a materialized view that references tables or views in the user's own schema. Enable rewrite using a materialized view when that materialized view references tables or views in any schema. Create a refresh-on-commit materialized view on any table in the database. Alter a refresh-on-demand materialized on any table in the database to refreshon-commit.
MATERIALIZED VIEWS:
CREATE MATERIALIZED VIEW
QUERY REWRITE
ON COMMIT REFRESH
Issue a SQL Flashback Query on any table, view, or materialized view in any schema. This privilege is not needed to execute
OPERATORS:
CREATE OPERATOR
-Create an operator and its bindings in the grantee's schema. Create an operator and its bindings in any schema and create a comment on an operator in any schema. Modify an operator in any schema. Drop an operator in any schema. Reference an operator in any schema. -Create public outlines that can be used in any schema that uses outlines. Modify outlines. Drop outlines. -Create stored procedures, functions, and packages in the grantee's schema. Create stored procedures, functions, and packages in any schema. Alter stored procedures, functions, or packages in any schema. Drop stored procedures, functions, or packages in any schema. Execute procedures or functions, either standalone or packaged. Reference public package variables in any schema.
OUTLINES:
CREATE ANY OUTLINE
PROCEDURES:
CREATE PROCEDURE
PROFILES:
--
Operations Authorized Create profiles. Alter profiles. Drop profiles. -Create roles. Alter any role in the database. Drop roles. Grant any role in the database. -Create rollback segments. Alter rollback segments. Drop rollback segments. -Create sequences in the grantee's schema. Create sequences in any schema. Alter any sequence in the database. Drop sequences in any schema. Reference sequences in any schema. -Connect to the database. Set costs for session resources. Issue ALTER SESSION statements. Logon after the instance is started using the SQL*Plus STARTUP RESTRICT statement.
ROLES:
CREATE ROLE ALTER ANY ROLE DROP ANY ROLE GRANT ANY ROLE
ROLLBACK SEGMENTS:
CREATE ROLLBACK SEGMENT ALTER ROLLBACK SEGMENT DROP ROLLBACK SEGMENT
SEQUENCES:
CREATE SEQUENCE
CREATE ANY SEQUENCE ALTER ANY SEQUENCE DROP ANY SEQUENCE SELECT ANY SEQUENCE
SESSIONS:
CREATE SESSION ALTER RESOURCE COST ALTER SESSION RESTRICTED SESSION
Operations Authorized See MATERIALIZED VIEWS -Create synonyms in the grantee's schema. Create private synonyms in any schema. Create public synonyms. Drop private synonyms in any schema. Drop public synonyms. Note: For external tables, the only valid privileges are CREATE ANY TABLE, ALTER ANY TABLE, DROP ANY TABLE, and SELECT ANY TABLE. Create tables in the grantee's schema. Create tables in any schema. The owner of the schema containing the table must have space quota on the tablespace to contain the table. Alter any table or view in any schema. Use the Export utility to incrementally export objects from the schema of other users. Delete rows from tables, table partitions, or views in any schema. Drop or truncate tables or table partitions in any schema. Insert rows into tables and views in any schema. Lock tables and views in any schema. Query tables, views, or materialized views in any schema.
TABLES:
Operations Authorized Issue a SQL Flashback Query on any table, view, or materialized view in any schema. This privilege is not needed to execute the DBMS_FLASHBACK procedures. Update rows in tables and views in any schema. -Create tablespaces. Alter tablespaces. Drop tablespaces. Take tablespaces offline and online and begin and end tablespace backups. Use an unlimited amount of any tablespace. This privilege overrides any specific quotas assigned. If you revoke this privilege from a user, then the user's schema objects remain but further tablespace allocation is denied unless authorized by specific tablespace quotas. You cannot grant this system privilege to roles. -Create a database trigger in the grantee's schema. Create database triggers in any schema. Enable, disable, or compile database triggers in any schema. Drop database triggers in any schema. Create a trigger on DATABASE. You must also have the CREATE TRIGGER or CREATE ANY TRIGG ER system privilege. --
TABLESPACES:
CREATE TABLESPACE ALTER TABLESPACE DROP TABLESPACE MANAGE TABLESPACE
UNLIMITED TABLESPACE
TRIGGERS:
CREATE TRIGGER
TYPES:
Operations Authorized Create object types and object type bodies in the grantee's schema. Create object types and object type bodies in any schema. Alter object types in any schema. Drop object types and object type bodies in any schema. Use and reference object types and collection types in any schema, and invoke methods of an object type in any schema if you make the grant to a specific user. If you grant EXECUTE ANY TYPEto a role, then users holding the enabled role will not be able to invoke methods of an object type in any schema. Create subtypes under any nonfinal object types. -Create users. This privilege also allows the creator to: Assign quotas on any tablespace. Set default and temporary tablespaces. Assign a profile as part of a CREATE USER statement.
USERS:
CREATE USER
ALTER USER
Alter any user. This privilege authorizes the grantee to: Change another user's password or authentication method. Assign quotas on any tablespace. Set default and temporary tablespaces. Assign a profile and default roles.
DROP USER
Drop users --
VIEWS:
Operations Authorized Create views in the grantee's schema. Create views in any schema. Drop views in any schema. Create subviews under any object views. Issue a SQL Flashback Query on any table, view, or materialized view in any schema. This privilege is not needed to execute the DBMS_FLASHBACK procedures. If a user has been granted the MERGE ANY VIEW privilege, then for any query issued by that user, the optimizer can use view merging to improve query performance without performing the checks that would otherwise be performed to ensure that view merging does not violate any security intentions of the view creator. See also Oracle Database Reference for information on theOPTIMIZER_SECURE_VIEW_MERGING par ameter and Oracle Database Performance Tuning Guide for information on view merging. -Analyze any table, cluster, or index in any schema. Audit any object in any schema using AUDIT schema_objects statements . Create a registration on queries and receive database change notifications in response to DML or DDL changes to the objects associated with the registered queries. Please refer to Oracle Database Application Developer's Guide - Fundamentals for more information on database change
MISCELLANEOUS:
ANALYZE ANY
AUDIT ANY
CHANGE NOTIFICATION
Comment on any table, view, or column in any schema. Bypass fine-grained access control. Caution: This is a very powerful system privilege, as it lets the grantee bypass application-driven security policies. Database administrators should use caution when granting this privilege.
Force the commit or rollback of any indoubt distributed transaction in the local database. Induce the failure of a distributed transaction.
FORCE TRANSACTION
Force the commit or rollback of the grantee's in-doubt distributed transactions in the local database. Grant any object privilege that the object owner is permitted to to grant. Revoke any object privilege that was granted by the object owner or by some other user with the GRANT ANY OBJECT PRIVILEGE privile ge.
Grant any system privilege. Enable resumable space allocation. Query any data dictionary object in the SYS schema. This privilege lets you selectively override the default FALSE setting of the O7_DICTIONARY_ACCESSIBILITY initi alization parameter. Query the contents of the FLASHBACK_TRANSACTION_QUERY view
Operations Authorized . Caution: This is a very powerful system privilege, as it lets the grantee view all data in the database, including past data. This privilege should be granted only to users who need to use the Oracle Flashback Transaction Query feature.
SYSDBA
and RECOVERY.
CREATE SPFILE.
up.
ARCHIVELOG
and RECOVERY.
CREATE SPFILE.
These roles are provided for compatibility with previous versions of Oracle Database. You can determine the privileges encompassed by these roles by querying the DBA_SYS_PRIVS data dictionary view. Note: Oracle recommends that you
Operations Authorized design your own roles for database security rather than relying on these roles. These roles may not be created automatically by future versions of Oracle Database. See Also: Oracle Database Reference for a description of the DBA_SYS_PRIVS view
DELETE_CATALOG_ROLEEXECUTE_CATALOG_ROLESE LECT_CATALOG_ROLE
These roles are provided for accessing data dictionary views and packages. See Also: Oracle Database Administrator's Guide for more information on these roles
EXP_FULL_DATABASE IMP_FULL_DATABASE
These roles are provided for convenience in using the import and export utilities. See Also: Oracle Database Utilities for more information on these roles
AQ_USER_ROLE AQ_ADMINISTRATOR_ROLE
You need these roles to use Oracle Advanced Queuing. See Also: Oracle Streams Advanced Queuing User's Guide and Reference for more information on these roles
SNMPAGENT
This role is used by the Enterprise Manager Intelligent Agent. See Also: Oracle Enterprise Manager Administrator's Guide
RECOVERY_CATALOG_OWNER
You need this role to create a user who owns a recovery catalog. See Also: Oracle Database Backup and Recovery Advanced User's Guide for more information on recovery catalogs
Purpose A DBA using Oracle Database heterogeneous services needs this role to access appropriate tables in the data dictionary. See Also: Oracle Database Heterogeneous Connectivity Administrator's Guide for more information
SCHEDULER_ADMIN
This role allows the grantee to execute the procedures of the DBMS_SCHEDULER package. It includes all of the job scheduler system privileges and is included in the DBA role. See Also: Oracle Database Administrator's Guide for more information on the DBMS_SCHEDULER package
Table 18-3 Object Privileges Available for Particular Objects Proc edur e, Fun ction , Pack age (Not e 1) ---
Object Privileg e
ALTER
T a bl e X X
V i e w -X
Seq uen ce X --
Li br ar y ---
Op erat or ---
(N
ote 2)
DELETE
EXECUTE
--
--
--
X (Not e 2)
--
--
X (N ote 2)
X (N ote 2) X
X (No te 2) --
X (Not e 2) --
DEBUG
--
--
--
--
Object Privileg e
FLASHBAC K INDEX INSERT
T a bl e X X X
V i e w X -X
Li br ar y ----
Op erat or ----
--
--
--
--
--
--
--
--
--
X -X X -X
--X X X X
---X ---
-------
---X -X (No te 3) --
-X -----
-------
----X --
-------
-------
WRITE
--
--
--
--
--
--
--
--
Note 1: Oracle Database treats a Java class, source, or resource as if it were a procedure for purposes of granting object privileges. Note 2: Job scheduler objects are created using the DBMS_SCHEDULER package. After these objects are created, you can
grant the EXECUTE object privilege on job scheduler classes and programs. You can grant ALTER privilege on job scheduler jobs, programs, and schedules. Note 3: The DELETE, INSERT, and updatable materialized views.
UPDATE
Table 18-4 Object Privileges and the Operations They Authorize Object Privilege TABLE PRIVILEGES Operations Authorized The following table privileges authorize operations on a table. Any one of following object privileges allows the grantee to lock the table in any lock mode with the LOCK TABLE statement. Note: For external tables, the only valid object privileges are ALTER and SELECT.
ALTER DELETE
Change the table definition with the ALTER TABLE statement. Remove rows from the table with the DELETE statement. Note: You must grant the SELECT privilege on the table along with the DELETE privilege if the table is on a remote database.
DEBUG
Access, through a debugger: PL/SQL code in the body of any triggers defined on the table Information on SQL statements that reference the table directly
Create an index on the table with the CREATE INDEX statement. Add new rows to the table with the INSERT statement. Create a constraint that refers to the table. You cannot grant this privilege to a role. Query the table with the SELECT statement. Change data in the table with the UPDATE statement. Note: You must grant the SELECT privilege on the table along with the UPDATE privilege if the table is on a remote database.
SELECT UPDATE
VIEW PRIVILEGES
The following view privileges authorize operations on a view. Any one of the following object privileges allows the grantee to lock the view in any lock mode with the LOCK TABLE statement. To grant a privilege on a view, you must have that privilege with the GRANT OPTION on all of the base tables of the view.
Object Privilege
DEBUG
Operations Authorized Access, through a debugger: PL/SQL code in the body of any triggers defined on the view Information on SQL statements that reference the view directly
Remove rows from the view with the DELETE statement. Add new rows to the view with the INSERT statement. Define foreign key constraints on the view. Query the view with the SELECT statement. Create a subview under this view. You can grant this object privilege only if you have the UNDER ANY VIEW privilege WITH GRANT OPTION on the immediate superview of this view. Change data in the view with the UPDATE statement. The following sequence privileges authorize operations on a sequence. Change the sequence definition with the ALTER SEQUENCE statement. Examine and increment values of the sequence with the CURRVAL and NEXTVAL pseudocolumns. The following procedure, function, and package privileges authorize operations on procedures, functions, and packages. These privileges also apply to Java sources, classes, and resources, which Oracle Database treats as though they were procedures for purposes of granting object privileges. Access, through a debugger, all public and nonpublic variables, methods, and types defined on the object. Place a breakpoint or stop at a line or instruction boundary within the procedure, function, or package. This privilege grants access to the declarations in the method or package specification and body.
UPDATE
SEQUENCE PRIVILEGES
ALTER
SELECT
EXECUTE
Execute the procedure or function directly, or access any program object declared in the specification of a package, or compile the object implicitly during a call to a currently invalid or uncompiled function or procedure. This privilege does not allow the grantee to explicitly compile using ALTER
Object Privilege
Operations Authorized or ALTER FUNCTION. For explicit compilation you need the appropriate ALTER system privilege.
PROCEDURE
Access, through a debugger, public variables, types, and methods defined on the procedure, function, or package. This privilege grants access to the declarations in the method or package specification only. Note: Users do not need this privilege to execute a procedure, function, or package indirectly. See Also: Oracle Database Concepts and Oracle Database Application Developer's Guide - Fundamentals MATERIALIZED VIEW PRIVILEGES
ON COMMIT REFRESH
The following materialized view privileges authorize operations on a materialized view. Create a refresh-on-commit materialized view on the specified table. Create a materialized view for query rewrite using the specified table. Query the materialized view with the SELECT statement. Synonym privileges are the same as the privileges for the base object. Granting a privilege on a synonym is equivalent to granting the privilege on the base object. Similarly, granting a privilege on a base object is equivalent to granting the privilege on all synonyms for the object. If you grant to a user a privilege on a synonym, then the user can use either the synonym name or the base object name in the SQL statement that exercises the privilege. The following directory privileges provide secured access to the files stored in the operating system directory to which the directory object serves as a pointer. The directory object contains the full path name of the operating system directory where the files reside. Because the files are actually stored outside the database, Oracle Database server processes also need to have appropriate file permissions on the file system server. Granting object privileges on the directory database object to individual database users, rather than on the operating system, allows the database to enforce security during file operations. Read files in the directory.
QUERY REWRITE
SELECT
SYNONYM PRIVILEGES
DIRECTORY PRIVILEGES
READ
Object Privilege
Operations Authorized
WRITE
Write files in the directory. This privilege is useful only in connection with external tables. It allows the grantee to determine whether the external table agent can write a log file or a bad file to the directory. Restriction: This privilege does not allow the grantee to write to a BFILE.
LIBRARY PRIVILEGE
EXECUTE
The following library privilege authorizes operations on a library. Use and reference the specified object and invoke its methods. The following object type privileges authorize operations on a database object type. Access, through a debugger, all public and nonpublic variables, methods, and types defined on the object type. Place a breakpoint or stop at a line or instruction boundary within the type body.
EXECUTE
Use and reference the specified object and invoke its methods. Access, through a debugger, public variables, types, and methods defined on the object type.
UNDER
Create a subtype under this type. You can grant this object privilege only if you have the UNDER ANY TYPE privilege WITH GRANT OPTION on the immediate supertype of this type. The following indextype privilege authorizes operations on indextypes. Reference an indextype. The following operator privilege authorizes operations on user-defined operators. Reference an operator.
INDEXTYPE PRIVILEGE
EXECUTE
OPERATOR PRIVILEGE
EXECUTE
To view how many rows in a table sql> desc dba_tables----->select num_rows where table_name=<tbl name> if table is not analysed it shows empty To analyse tables :sql>analyze table <table name> validate structure; Then sql> desc dba_tables----->select num_rows now it show exact number of rows To know how many rows in a table by default: select count(*) table_name To know how many tables the user own: select *from tab To create new user :conn as sysdba create user <UN> identified by <password>,default tablespace users quota 500k on users,create profile supervisor; To grant privilege as sysdba: SQL> grant create session to mohan; Grant succeeded. SQL> grant create table to mohan; Grant succeeded. To select any dictionary by user :SQL>grant select any dictionary to mohan; To know the roles what are assigned to user: desc user_role_privs; As sysdba to grant role for another user: grant select,insert,delete,update on mohan.rac(user.tbl name) to tl; Flashback: SQL> select * from v$flash_recovery_area_usage;
FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES ------------ ------------------ ------------------------- --------------CONTROLFILE ONLINELOG ARCHIVELOG BACKUPPIECE IMAGECOPY 0 0 3.65 0 0 0 0 0 0 0 0 0 8 0 0
FLASHBACKLOG
rows selected.
SQL> select * from V$RECOVERY_FILE_DEST; NAME --------------------------------------------------------------------------------SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES ----------- ---------- ----------------- --------------/u01/app/oracle/ 2147483648 78390272 0 8
dba_tab_columns dba_tables
dba_temp_files dba_triggers dba_ts_quotas dba_undo_extents dba_users dba_mview_logs dba_mview_refresh_times dba_mviews dba_part_tables dba_queues dba_resumable dba_tab_partitions
* dba_all_tables * dba_indexes * dba_ind_partitions * dba_ind_subpartitions * dba_object_tables * dba_part_col_statistics * dba_subpart_col_statistics * dba_tables * dba_tab_cols * dba_tab_columns * dba_tab_col_statistics * dba_tab_partitions
* dba_tab_subpartitions
V$views: v$archived_log v$asm_disk v$backup_datafile v$controlfile v$database v$datafile v$db_cache_advice v$filestat v$instance v$lock v$locked_object v$log v$logfile v$parameter v$process v$segment_statistics v$session v$session_longops v$session_wait v$sesstat v$sort_usage v$sqlarea v$statname v$sysstat v$system_event v$tempfile v$transaction
dba_segments: DBA_SEGMENTS describes the storage allocated for all segments in the database. This information has many uses, one of which is to find an objects size: col segment_name format a20 select segment_name , , bytes "SIZE_BYTES" ceil(bytes / 1024 / 1024) "SIZE_MB"
from dba_segments where segment_name like '&obj_name' / You can also use it to list all of the objects in a tablespace: set pages 999 col owner format a15 col segment_name format a40 col segment_type format a20 select owner , , segment_name segment_type
from dba_segments where lower(tablespace_name) like lower('%&tablespace%') order by owner, segment_name / Or to see which if any objects are approaching their maximum extent allocation (maxextents): col , , , , segment_name format a40 segment_type segment_name max_extents - extents as "spare" max_extents select owner
from dba_segments whereowner not in ('SYS','SYSTEM') and / (max_extents - extents) < 10 order by 4
To calculate allocated size for the table: Col TABLE_NAME FORMAT A32 COL OBJECT_NAME FORMAT A32 COL OWNER FORMAT A10 SELECT owner,blocks, table_name, TRUNC(sum(bytes)/1024/1024) Meg FROM (SELECT segment_name table_name, owner, bytes FROM dba_segments WHERE segment_type = 'TABLE' UNION ALL SELECT i.table_name, i.owner, s.bytes FROM dba_indexes i, dba_segments s WHERE s.segment_name = i.index_name AND s.owner = i.owner AND s.segment_type = 'INDEX' UNION ALL SELECT l.table_name, l.owner, s.bytes FROM dba_lobs l, dba_segments s WHERE s.segment_name = l.segment_name AND s.owner = l.owner AND s.segment_type = 'LOBSEGMENT' UNION ALL SELECT l.table_name, l.owner, s.bytes FROM dba_lobs l, dba_segments s WHERE s.segment_name = l.index_name AND s.owner = l.owner AND s.segment_type = 'LOBINDEX') WHERE owner in UPPER('&owner') GROUP BY table_name, owner HAVING SUM(bytes)/1024/1024 > 10 /* Ignore really small tables */ ORDER BY SUM(bytes) desc ; Space growth in weekly basis:
create table space_growth (owner,tablespace , Name ,GB,week)
select owner, tablespace, name, gb, lag(gb) over (partition by owner, name order by week) last_gb, week, week-lag(week) over (partition by owner, name order by week) num_days from space_growth;
( select nvl(sum(bytes),0)/1024/1024 temp_size from dba_temp_files ) b, ( select sum(bytes)/1024/1024 redo_size from sys.v_$log ) c, ( select sum(BLOCK_SIZE*FILE_SIZE_BLKS)/1024/1024 controlfile_size from v$controlfile) d;
Praveens Query : Query to view tablewise growth : set feedback on select * from (select c.TABLESPACE_NAME,c.segment_name "Object Name",b.object_type, sum(space_used_delta) / 1024 / 1024 "Growth (MB)" from dba_hist_snapshot sn, dba_hist_seg_stat a, dba_objects b, dba_segments c where begin_interval_time > trunc(sysdate)-&days_back and sn.snap_id = a.snap_id and b.object_id = a.obj# and b.owner = c.owner and b.object_name = c.segment_name and c.owner =OWNER group by c.TABLESPACE_NAME,c.segment_name,b.object_type) order by 3 asc;
table growth:
column "Percent of Total Disk Usage" justify right format 999.99 column "Space Used (MB)" justify right format 9,999,999.99 column "Total Object Size (MB)" justify right format 9,999,999.99 set linesize 150 set pages 80 set feedback off select * from (select to_char(end_interval_time, 'MM/DD/YY') mydate, sum(space_used_delta) / 1024 / 1024 "Space used (MB)", avg(c.bytes) / 1024 / 1024 "Total Object Size (MB)", round(sum(space_used_delta) / sum(c.bytes) * 100, 2) "Percent of Total Disk Usage" from dba_hist_snapshot sn, dba_hist_seg_stat a, dba_objects b, dba_segments c where begin_interval_time > trunc(sysdate) - &days_back and sn.snap_id = a.snap_id and b.object_id = a.obj# and b.owner = c.owner and b.object_name = c.segment_name and
Rman backup errors : RMAN-03002: failure of backup plus archivelog command at 11/29/2011 04:35:27 ORA-19809: limit exceeded for recovery files ORA-19804: cannot reclaim 52428800 bytes disk space from 1072668082176 limit
To verify this run the following query. It will show the size of the recovery area and how full it is: set lines 100 col name format a60 select name , floor(space_limit / 1024 / 1024) "Size MB" , ceil(space_used / 1024 / 1024) "Used MB" from v$recovery_file_dest order by name / To fix the problem, you need to either make the flash recovery area larger, or remove some files from it. If you have the disk space available, make the recovery area larger: alter system set db_recovery_file_dest_size=<size> scope=both / To remove files you must use RMAN. Manually moving or deleting files will have no effect as oracle will be unaware. The obvious choice is to backup and remove some archive log files. However, if you usually write your RMAN backups to disk, this could prove tricky. RMAN will attempt to write the backup to the flash recovery area...which is full. You could try sending the backup elsewhere using a command such as this: rman target / catalog user/pass@rmancat run { allocate channel t1 type disk; backup archivelog all delete input format '/<temp backup location>/arch_%d_ %u_%s'; release channel t1; } This will backup all archive log files to a location of your choice and then remove them.
ORA-19804: cannot reclaim string bytes disk space from string limit
Cause: Oracle cannot reclaim disk space of specified bytes from the DB_RECOVERY_FILE_DEST_SIZE limit. Action: There are five possible solutions: 1) 2) 3) 4) 5) Take frequent backup of recovery area using RMAN. Consider changing RMAN retention policy. Consider changing RMAN archivelog deletion policy. Add disk space and increase DB_RECOVERY_FILE_DEST_SIZE. Delete files from recovery area using RMAN
List all tables owned by a user sorted by size set lines 100 pages 999 col segment_name format a40 col GB format 999,999,999 select segment_name , ceil(sum(bytes) / 1024 / 1024/1024) "GB" from dba_segments where owner like '&user' and segment_type = 'TABLE' group by segment_name order by ceil(sum(bytes) / 1024 / 1024) desc /