Vous êtes sur la page 1sur 7

10g/11g

VIEWS WE QUERY IN DATABASE 1} V$CONTROLFILE > Lists the names and status of the control files. 2} V$DATABASE 3} V$DATAFILE 4} V$INSTANCE 5} V$PARAMETER the 6} V$SESSION 7} V$SGA Contains database information from the control files. Contains data file information from control file. Displays the state of the current instance. Lists parameters and values currently in effect for Session also status and location of all parameters. Lists session information for each current session. Contains summary information on SGA.

8} V$SPPARAMETER Lists the contents of SPFILE. 9} V$TABLESPACE 10} V$THREAD 11} V$VERSION Displays tablespace information from the control file. Contains thread information from control file. Version numbers of core library components in oracle server.

12} V$FIXED_TABLE To find list of data dictionary views. 13} V$CONTROLFILE_RECORD_SECTION > Provides information about the Control file record section. 14}SHOW PARAMETER CONTROL_FILES Lists the name, status and location of Control files. 15}V$THREAD >To display the current redo log group, the no. of online redo log groups and current sequence number. 16} V$LOGFILE >Displays each redo log group, member and status of each Member. 17} V$LOG > Same as above.

18} V$DATABASE_PROPERTIES Name of default tablespaces. 19}V$DBA_TABLESPACES Complete information about tablespaces. 20}V$DBA_DATA_FILES Complete information of the files present in the Tablespaces. 21} V$DBA_TEMP_FILES Files information of temporary tablespace.

22} V$DBA_EXTENTS

>To check the extents for a given segment.

23} V$DBA_SEGMENTS View to get number of extents and blocks allocated to a Segment. 24} V$DBA_FREE_SPACE Displays free extents in tablespace. 25} V$DBA_ROLLBACK_SEGS To obtain information about all the undo segments In the database. {IMP*:-Information about undo segments that are offline can be seen only in this view.} 26}V$ROLLSTAT & V$ROLLNAME Views to obtain the statistics of the undo Segments currently used by the instance. 27} V$TRANSACTION & V$SESSION To check the use of a undo segment by Currently active transactions. 28} V$DBA_TABLES All the information about tables can be obtained here.

29} V$DBA_OBJECTS >All the information about objects in table can be Obtained here. 30} V$DBA_UNUSED_COL_TABS To identify tables with unused columns. 31} V$DBA_PARTIAL_DROP_TABS To identify tables that have partially Completed DROP columns operations. 32}V$DBA_INDEXES >Provides information on the indexes.

33}V$DBA_IND_COLUMNS Provides information on the columns indexed. 34}V$OBJECT _USAGE Provides information on the usage of an index.

35}V$DBA_CONSTRAINTS To obtain name, type and status of all constraints. 36}V$DBA_CONS_COLUMNS To obtain the columns in the constraints on table. 37}V$DBA_USERS >To obtain information about account status, default Tablespace for users. 38}V$DBA_PROPERTIES 39}V$DBA_TS_QUOTAS 40}V$DBA_SYS_PRIVS 41} V$SESSION_PRIVS View to display passwd profile information. Amount of space a user can use in tablespaces. Lists system privileges granted to users and roles. Lists the privileges that are currently available to user.

42} V$DBA_TAB_PRIVS Lists all grants on all objects in the database.

43}V$DBA_COL_PRIVS 44}V$DBA_ROLES

Describes all object grants in the database. All roles that exist in the database.

45}V$DBA_ROLES_PRIVS Roles granted to users and roles. 46}V$ROLE_ROL_PRIVS Roles that are granted to roles. 47}V$DBA_SYS_PRIVS System privileges granted to users and roles.

48}V$ROLE_SYS_PRIVS System privileges granted to roles. 49}V$ROLE_TAB_PRIVS Object privileges granted to roles. 50}V$SESSION_ROLES Roles that the user currently has enabled.

creating a synonym
Database links are notoriously slow, not an optimal solution for applications needing real-time response. Expect the database link to cause a delay in accessing the remote data. Here is an example of creating a synonym for scott's database link. SQL> create synonym rem_emp for emp@remotedb; Synonym created. SQL> select count(*) from rem_emp; COUNT(*) ---------14 The other method is to create a view on your remote database's data. SQL> create view v_emp as select * from emp@remotedb; View created. SQL> select count(*) from v_emp; COUNT(*) ---------14

How to drop a database link


Dropping a database link from your Oracle database is as easy as doing the following: drop database link remotedb; or drop public database link remotedb; You will need no other system privilege other than the 'create database link' privilege granted directly to your username or granted via a role to drop your own database link. It is not possible to drop a database link belonging to another user. If you try to specify another schema's database link by qualifying it with a name, Oracle will just look for a private database link in your schema with a name which includes the other schema's name and will not find it. To drop a public database link, you will need the system privilege 'drop public database link'. For example: SQL> connect / as sysdba Connected. SQL> drop database link scott.remotedb; drop database link scott.remotedb * ERROR at line 1: ORA-02024: database link not found SQL> connect scott/tiger Connected. SQL> drop database link scott.remotedb; drop database link scott.remotedb * ERROR at line 1: ORA-02024: database link not found SQL> drop database link remotedb; Database link dropped.

how to create a db link

Once a database link has been created you are now ready to select your data from the remote database referenced by the db link. The syntax is : select from @; For example: SQL> select * from dept@remotedb; DEPTNO DNAME LOC ---------- -------------- ------------10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON

The database link is opened during the select (or other DML transaction) and remains open for the duration of the session. After you close a session, the links that were active in the session are automatically closed. Close a db link To explicitly close the database link , use the command below: SQL> alter session close database link remotedb; Session altered. Using db links in other DML statements You can use insert/update/delete statements just as easily with database links SQL> select * from dept@remotedb; DEPTNO DNAME LOC ---------- -------------- ------------10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON SQL> insert into dept@remotedb (deptno,dname,loc) 2 values (50,'MARKETING','BOISE'); 1 row created.

SQL> commit; Commit complete. SQL> select * from dept@remotedb; DEPTNO DNAME LOC ---------- -------------- ------------10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON 50 MARKETING BOISE

SQL> update dept@remotedb set loc = 'LONDON' where deptno = 50; 1 row updated. SQL> commit; Commit complete. SQL> select * from dept@remotedb; DEPTNO DNAME LOC ---------- -------------- ------------10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON 50 MARKETING LONDON SQL> delete from dept@remotedb where dname = 'MARKETING'; 1 row deleted. SQL> commit; Commit complete. SQL> select * from dept@remotedb; DEPTNO DNAME LOC ---------- -------------- ------------10 ACCOUNTING NEW YORK

20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON

Note that DDL operations are not allowed through a database link: SQL> alter table dept@remotedb add column (manager varchar2(30)); alter table dept@remotedb add column (manager varchar2(30)) * ERROR at line 1: ORA-02021: DDL operations are not allowed on a remote database