Showing posts with label DBA. Show all posts
Showing posts with label DBA. Show all posts

Monday, 9 January 2017

V$ Views


The following table has the dynamic performance views. You need DBA privileges to access these views.
View NameDescription
V$BGPROCESSOracle background processes
V$CONTROLFILEThe names of the control files
V$DATABASEInformation about the database from the control file
V$DATAFILEInformation about the data files from the control file
V$ENABLEDPRIVSEnabled privileges
V$FILESTATI/O activity per data file
V$FIXED_TABLEDisplays all dynamic performance tables, views, and derived tables
V$FIXED_VIEW_DEFINITIONDisplays the definitions of all the fixed views
V$INSTANCEStatus about the instance
V$LICENSEAbout license limits
V$LOCKabout active locks
V$MYSTATStatistics for the current session
V$NLS_PARAMETERSCurrent NLS parameter values
V$NLS_VALID_VALUESAll valid values for NLS parameters
V$OPTIONThe installed Oracle options
V$PARAMETERCurrent initialization parameter values for the session
V$PROCESSInformation about all active processes
V$RESERVED_WORDSAll keywords used by the PL/SQL compiler
V$SESS_IOI/O statistics for all active sessions
V$SESSIONAbout all active sessions
V$SESSION_EVENTWaits for an event by a session
V$SESSION_LONGOPSStatus of operations that run for longer than 6 seconds
V$SESSION_WAITResources or events for which active sessions are waiting
V$SESSTATUser session statistics
V$SGARhe shared global area
V$SGASTATSGA components
V$SPPARAMETERThe contents of the server parameter file
V$SQLSQL statements in memory
V$SQLAREAAggregated information about SQL statements in memory
V$SQL_PLANExecution plan information for SQL statements in memory
V$SQL_PLAN_STATISTICSExecution statistics of SQL statements in memory
V$SQLTEXTThe text of SQL statements in memory
V$SQLTEXT_WITH_NEWLINESSame as V$SQLTEXT, with improved legibility
V$SYSSTATAll system statistics
V$SYSTEM_PARAMETERInformation about the initialization parameters in effect
V$TABLESPACEAll tablespaces
V$TIMERInternal clock, in hundredths of a second
V$TIMEZONE_NAMESList of names and abbreviations of time zones
V$TRANSACTIONAll active transactions
V$VERSIONVersion information about installed Oracle products
V$WAITSTATBlock contention statistics

DBA views


The views listed in the following table have database-wide information and are accessible only to DBA privileges.
View NameDescription
DBA_AUDIT_TRAILAll entries of the audit trail
DBA_CATALOGAll indexes, tables, views, clusters, synonyms, and sequences
DBA_COL_COMMENTSAll column comments
DBA_COL_PRIVSAll column privileges
DBA_CONSTRAINTSAll constraints
DBA_DATA_FILESAll data files belonging to the database
DBA_DB_LINKSAll database links
DBA_EXTENTSAll extents
DBA_FREE_SPACESummary of all free space
DBA_INDEXESDescription of all indexes
DBA_IND_COLUMNSDescription of all index columns
DBA_IND_EXPRESSIONSExpressions of all function-based indexes
DBA_LOCKSAll locks
DBA_MVIEWSAll materialized views
DBA_NESTED_TABLE_COLSAll columns of nested tables
DBA_NESTED_TABLESAll nested tables
DBA_OBJECTSAll database objects
DBA_RECYCLEBINAll dropped objects in the recycle bin
DBA_ROLE_PRIVSAll roles, granted to users or other roles
DBA_ROLESAll roles
DBA_SEGMENTSAll segments (e.g., tables and indexes)
DBA_SEQUENCESAll sequences
DBA_SYNONYMSAll synonyms
DBA_SYS_PRIVSAll system privileges granted to users or roles
DBA_TABLESDescription of all tables
DBA_TABLESPACESAll tablespaces
DBA_TAB_COLSDescription of all columns
DBA_TAB_COLUMNSDescription of all columns, without hidden columns
DBA_TAB_COMMENTSAll table comments
DBA_TAB_PRIVSAll table privileges
DBA_TS_QUOTASAll user quota, per tablespace
DBA_UPDATABLE_COLUMNSAll columns of updatable join views
DBA_USERSInformation about all users
DBA_VIEWSDescription of all views
DBA_WAITERSAll sessions waiting for something (locks)

USER View


Useful Shorthand Names for USER Views
View NameSynonym For
CATUSER_CATALOG
COLSUSER_TAB_COLUMNS
INDUSER_INDEXES
OBJUSER_OBJECTS
RECYCLEBINUSER_RECYCLEBIN
SEQUSER_SEQUENCES
SYNUSER_SYNONYMS
TABSUSER_TABLES
The following table has USER Data Dictionary Views. Regular database users have access to these views.
View NameDescription
USER_AUDIT_TRAILAudit trail entries
USER_CATALOGIndexes, tables, views, clusters, synonyms, and sequences
USER_COL_COMMENTSComments on your columns
USER_COL_PRIVSColumn privileges
USER_COL_PRIVS_MADEColumn privileges you made
USER_COL_PRIVS_RECDColumn privileges you received
USER_CONS_COLUMNSColumns involved in constraints
USER_CONSTRAINTSAll your constraints
USER_EXTENTSAll extents
USER_FREE_SPACEAvailable free space for creating objects
USER_INDEXESDescription of all your indexes
USER_IND_COLUMNSDescription of all your index columns
USER_IND_EXPRESSIONSDescription of all your function-based index expressions
USER_MVIEWSAll your materialized views
USER_NESTED_TABLE_COLSAll columns of your nested tables
USER_NESTED_TABLESAll your nested tables
USER_OBJECTSAll your object descriptions
USER_RECYCLEBINYour recycle bin
USER_ROLE_PRIVSRoles granted to you
USER_SEGMENTSStorage-related information about your objects
USER_SEQUENCESAll your sequences
USER_SYNONYMSAll your synonym definitions
USER_SYS_PRIVSSystem privileges you have
USER_TABLESDescription of your tables
USER_TAB_COLSDescription of your table columns
USER_TAB_COLUMNSDescription of your table columns, without hidden columns
USER_TAB_COMMENTSComments on your tables
USER_TAB_PRIVSTable privileges where you are involved
USER_TAB_PRIVS_MADETable privileges you made
USER_TAB_PRIVS_RECDTable privileges where you received
USER_TABLESPACESAccessible tablespaces
USER_TS_QUOTASQuota for accessible tablespaces
USER_UPDATABLE_COLUMNSColumns of updatable join views
USER_USERSInformation
USER_VIEWSDescription of all your views

ALL views


The following table lists views that have information about all accessible data. Regular database users have access to these views.
View NameDescription
ALL_CATALOGAll accessible database objects
ALL_COL_COMMENTSComments for all accessible columns
ALL_COL_PRIVSColumn privileges where you are involved
ALL_COL_PRIVS_MADEColumn privileges where you are the grantor
ALL_COL_PRIVS_RECDColumn privileges where you are the grantee
ALL_CONS_COLUMNSAll accessible constraint columns
ALL_CONSTRAINTSAll accessible constraint definitions
ALL_INDEXESDescriptions of all accessible indexes
ALL_IND_COLUMNSColumn descriptions of all accessible indexes
ALL_IND_EXPRESSIONSExpressions of all accessible function-based indexes
ALL_MVIEWSDescriptions for all accessible materialized views
ALL_NESTED_TABLE_COLSAll accessible columns of nested tables
ALL_NESTED_TABLESAll accessible nested tables
ALL_OBJECTSAll accessible database objects
ALL_SEQUENCESAll accessible sequences
ALL_SYNONYMSSynonyms
ALL_TABLESAll accessible tables
ALL_TAB_COLSColumn descriptions for all accessible tables
ALL_TAB_COLUMNSColumn descriptions for all accessible tables without hidden columns
ALL_TAB_COMMENTSAll comments for accessible tables
ALL_TAB_PRIVSTable privileges
ALL_TAB_PRIVS_MADETable privileges where you are object owner or grantor
ALL_TAB_PRIVS_RECDTable privileges where you are the privilege grantee
ALL_UPDATABLE_COLUMNSAccessible updatable join view columns
ALL_USERSInformation about all database users
ALL_VIEWSInformation about all accessible views

Creating Roles


A role is a group of privileges. The privileges can be assigned to a role, and then the role can be granted to multiple users and roles. When adding or deleting a privilege from a role, all users and roles assigned that role automatically receive or lose that privilege. A user or role can have multiple roles. A role can have a password. The roles can help you manage multiple privileges assigned to multiple users.

Creating Roles

To create a role, you must have the CREATE ROLE system privilege.

GRANT CREATE ROLE TO store;
GRANT CREATE USER TO store WITH ADMIN OPTION;
You create a role using the CREATE ROLE statement. The default is to do both.

CREATE ROLE firstRole;
CREATE ROLE secondRole IDENTIFIED by password;

GRANT SELECT, INSERT, UPDATE, DELETE ON employee TO firstRole;
GRANT SELECT, INSERT, UPDATE, DELETE ON products TO firstRole;
GRANT firstRole TO secondRole;

Synonyms

You can access tables in another schema by specifying the schema name followed by the table. For employee table in the store schema, store.employee is used. You can avoid referencing schema name by creating a synonym for that table. A Synonym is created by CREATE SYNONYM command.

GRANT CREATE SYNONYM TO steve;
CREATE SYNONYM employee FOR store.employee;

Object Privileges

An object privilege allows a user to perform certain actions on database objects. For example, a user can execute DML statements on tables.
Object PrivilegeAllows a User to...
SELECTPerform a select.
INSERTPerform an insert.
UPDATEPerform an update.
DELETEPerform a delete.
EXECUTEExecute a stored procedure.

Granting Object Privileges to a User

GRANT command grants an object privilege to a user.

GRANT SELECT, INSERT, UPDATE ON store.products TO tom;
GRANT SELECT ON store.employees TO tom;
The next example grants the UPDATE privilege on the last_name and sal columns to tom:

GRANT UPDATE (last_name, sal) ON store.employees TO tom;
The following example uses the GRANT option to enable a user to grant a privilege to another user.

GRANT SELECT ON store.employee TO tom WITH GRANT OPTION;
GRANT OPTION grants an object privilege to another user, and ADMIN OPTION grants a system privilege to another user.
The SELECT ON store.employee privilege can then be granted to another user by tom. The following example connects as tom and grants this privilege to another user:

CONNECT tom/password
GRANT SELECT ON store.employee TO anotherUser;

System Privileges

A system privilege allows a user to perform certain actions within the database, such as executing DDL statements.
The privileges can be grouped together into roles. Two useful roles to grant to a user are CONNECT and RESOURCE. CONNECT allows a user to connect to the database. RESOURCE allows a user to create various database objects like tables.
Commonly Used System Privileges:
System PrivilegeAllows You to
CREATE SESSIONConnect to a database.
CREATE SEQUENCECreate a sequence
CREATE SYNONYMCreate a synonym.
CREATE TABLECreate a table in the user's schema.
CREATE ANY TABLECreate a table in any schema.
DROP TABLEDrop a table from the user's schema.
DROP ANY TABLEDrop a table from any schema.
CREATE PROCEDURECreate a stored procedure.
EXECUTE ANY PROCEDUREExecute a procedure in any schema.
CREATE USERCreate a user.
DROP USERDrop a user.
CREATE VIEWCreate a view.

Granting System Privileges to a User

You use GRANT to grant a system privilege to a user.

GRANT CREATE SESSION, CREATE USER, CREATE TABLE TO tom;

Creating a User

To create a user in the database, you use the CREATE USER statement. The simplified syntax for the CREATE USER statement:

CREATE USER user_name IDENTIFIED BY password
[DEFAULT TABLESPACE default_tablespace]
[TEMPORARY TABLESPACE temporary_tablespace];
  • user_name is the name of the database user.
  • password is the password for the database user.
  • default_tablespace is the default tablespace where database objects are stored. If you omit a default tablespace, the default SYSTEM tablespace is used.
  • temporary_tablespace is the default tablespace where temporary objects are stored.
Tablespaces are used by the database to store separate objects. The following example connects as system and creates a user named tom with a password of Jerry:


CONNECT system/manager

SQL> CREATE USER tom IDENTIFIED BY Jerry;

User created.

SQL>
The following example creates a user named tom and specifies a default and temporary tablespace:

SQL> CREATE USER tom IDENTIFIED BY yourPassword
  2  DEFAULT TABLESPACE users
  3  TEMPORARY TABLESPACE temp;

User created.

SQL>
To view all table spaces

SELECT tablespace_name FROM dba_tablespaces.

Thursday, 19 March 2015

Query to list out the Schemas and the status of the products in Oracle Applications

SELECT   fou.oracle_id                                   "Oracle Id",
         fou.oracle_username                             "Schema Name",
         fa.application_short_name                       "Application Short Name",
         ft.application_name                             "Application Name",
         fa.product_code                                 "Product Code",
         fpi.product_version                             "Product Version",
         DECODE (fpi.status,
                 'I', 'Installed',
                 'N', 'Not Installed',
                 'S', 'Shared Install')                  "Installation Status",
         NVL (fpi.patch_level, '-- Not Available --')    "Patchset",
         TO_CHAR (fpi.last_update_date, 'dd-Mon-RRRR')   "Update Date"
    FROM fnd_oracle_userid fou,
         fnd_application fa,
         fnd_product_installations fpi,
         dba_users du,
         fnd_application_tl ft
   WHERE fpi.application_id = fa.application_id(+)
     AND fpi.oracle_id(+) = fou.oracle_id
     AND du.username(+) = fou.oracle_username
     AND ft.language(+) = 'US'
     AND ft.application_id(+) = fa.application_id
ORDER BY 2