Вы находитесь на странице: 1из 9

<---chapter 11----> <-----how to connect oracle server-------> <----listener is a process running on server side-----> first you delete admin

network already created <---listener.ora---> or <---tnsna mes.ora---> files and then start new terminals.. $netmgr alter system set dispatchers='(protocol=tcp)(dispatchers=3)(service=MKTG.world)' ; select * from v$session<----- to show sessions-----> select * from v$session where usename is not null <---- to neglate background pr ocess------> SQL> show parameter service; NAME TYPE VALUE ------------------------------------ ----------- -----------------------------service_names string MKTG.world SQL> show parameter shared_server; NAME -----------------------------------max_shared_servers shared_server_sessions shared_servers SQL> show parameter dispatche TYPE VALUE ----------- -----------------------------integer integer integer 1

NAME TYPE VALUE ------------------------------------ ----------- -----------------------------dispatchers string (PROTOCOL=TCP) (SERVICE=MKTGXD B) max_dispatchers integer SQL> alter system set dispatchers='(protocol=tcp)(dispatchers=3)(service=MKTG.wo rld)'; System altered. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, OLAP and Data Mining options SQL> exit; Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64 bit Production With the Partitioning, OLAP and Data Mining options oracle@w7dell4:~$ lsnrctl status LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 23-DEC-2011 12:32:06 Copyright (c) 1991, 2005, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=w7dell4)(PORT=1521))) STATUS of the LISTENER -----------------------Alias LISTENER Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production Start Date 23-DEC-2011 10:52:00

Uptime 0 days 1 hr. 40 min. 6 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/10.2.0/db_3/network/admin/list ener.ora Listener Log File /u01/app/oracle/product/10.2.0/db_3/network/log/listen er.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=w7dell4)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0))) Services Summary... Service "MKTG.world" has 1 instance(s). Instance "MKTG", status READY, has 4 handler(s) for this service... Service "MKTGXDB.world" has 1 instance(s). Instance "MKTG", status READY, has 0 handler(s) for this service... Service "MKTG_XPT.world" has 1 instance(s). Instance "MKTG", status READY, has 1 handler(s) for this service... Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully oracle@w7dell4:~$ lsnrctl stop LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 23-DEC-2011 12:33:54 Copyright (c) 1991, 2005, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=w7dell4)(PORT=1521))) The command completed successfully oracle@w7dell4:~$ lnsrctl start lnsrctl: command not found oracle@w7dell4:~$ lsnrctl start LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 23-DEC-2011 12:34:26 Copyright (c) 1991, 2005, Oracle. All rights reserved. Starting /u01/app/oracle/product/10.2.0/db_3/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 10.2.0.1.0 - Production System parameter file is /u01/app/oracle/product/10.2.0/db_3/network/admin/liste ner.ora Log messages written to /u01/app/oracle/product/10.2.0/db_3/network/log/listener .log Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=w7dell4)(PORT=1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=w7dell4)(PORT=1521))) STATUS of the LISTENER -----------------------Alias LISTENER Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production Start Date 23-DEC-2011 12:34:26 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/10.2.0/db_3/network/admin/list ener.ora Listener Log File /u01/app/oracle/product/10.2.0/db_3/network/log/listen er.log

Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=w7dell4)(PORT=1521))) The listener supports no services The command completed successfully oracle@w7dell4:~$ lsnrctl status LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 23-DEC-2011 12:34:44 Copyright (c) 1991, 2005, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=w7dell4)(PORT=1521))) STATUS of the LISTENER -----------------------Alias LISTENER Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production Start Date 23-DEC-2011 12:34:26 Uptime 0 days 0 hr. 0 min. 18 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/10.2.0/db_3/network/admin/list ener.ora Listener Log File /u01/app/oracle/product/10.2.0/db_3/network/log/listen er.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=w7dell4)(PORT=1521))) The listener supports no services The command completed successfully oracle@w7dell4:~$ lsnrctl status LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 23-DEC-2011 12:35:46 Copyright (c) 1991, 2005, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=w7dell4)(PORT=1521))) STATUS of the LISTENER -----------------------Alias LISTENER Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production Start Date 23-DEC-2011 12:34:26 Uptime 0 days 0 hr. 1 min. 20 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/10.2.0/db_3/network/admin/list ener.ora Listener Log File /u01/app/oracle/product/10.2.0/db_3/network/log/listen er.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=w7dell4)(PORT=1521))) Services Summary... Service "MKTG.world" has 1 instance(s). Instance "MKTG", status READY, has 4 handler(s) for this service... Service "MKTGXDB.world" has 1 instance(s). Instance "MKTG", status READY, has 0 handler(s) for this service... Service "MKTG_XPT.world" has 1 instance(s). Instance "MKTG", status READY, has 1 handler(s) for this service... The command completed successfully oracle@w7dell4:~$ oracle@w7dell4:~$ lsnrctl stop

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 23-DEC-2011 12:40:41 Copyright (c) 1991, 2005, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=w7dell4)(PORT=1521))) The command completed successfully oracle@w7dell4:~$ lsnrctl start LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 23-DEC-2011 12:40:45 Copyright (c) 1991, 2005, Oracle. All rights reserved. Starting /u01/app/oracle/product/10.2.0/db_3/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 10.2.0.1.0 - Production System parameter file is /u01/app/oracle/product/10.2.0/db_3/network/admin/liste ner.ora Log messages written to /u01/app/oracle/product/10.2.0/db_3/network/log/listener .log Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=w7dell4)(PORT=1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=w7dell4)(PORT=1521))) STATUS of the LISTENER -----------------------Alias LISTENER Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production Start Date 23-DEC-2011 12:40:45 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/10.2.0/db_3/network/admin/list ener.ora Listener Log File /u01/app/oracle/product/10.2.0/db_3/network/log/listen er.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=w7dell4)(PORT=1521))) Services Summary... Service "MKTG.world" has 1 instance(s). Instance "MKTG", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully oracle@w7dell4:~$ <-------lsnrctl means listner control-------> <-------how to directly connect by the server oracle 10g can provide directly co nnect to the server using ip address and port------> sqlplus scott/tiger@192.168.0.102:1521/orcl.world <---- direcctly connect to the server-----> create global temporary table scott.gt1 on commit delete rows as select * from s cott.emp; insert into scott.gt1(empno) values(1); commit; select * from scott.gt1;

create global temporary table scott.gt2 on commit preserve rows as select * from scott.emp; insert into scott.gt2 (empno)values(1); select * from scott.gt2; commit; SQL> create global temporary table scott.gt1 on commit delete rows as select * f rom scott.emp; Table created. SQL> insert into scott.gt1 values(1); insert into scott.gt1 values(1) * ERROR at line 1: ORA-00947: not enough values SQL> insert into scott.gt1(empno) values(1); 1 row created. SQL> commit; Commit complete. SQL> select * from scott.gt1; no rows selected SQL> create global temporary table scott.gt2 on commit preserve rows as select * from scott.emp; Table created. SQL> insert into scott.gt2 (empno)values(1); select * from scott.gt2; commit; 1 row created. SQL> SQL> EMPNO ENAME JOB MGR HIREDATE SAL COMM ---------- ---------- --------- ---------- --------- ---------- ---------DEPTNO ---------7369 SMITH CLERK 7902 17-DEC-80 900 20 7499 ALLEN 30 7521 WARD 30 SALESMAN SALESMAN 7698 20-FEB-81 7698 22-FEB-81 1700 1350 300 500

EMPNO ENAME JOB MGR HIREDATE SAL COMM ---------- ---------- --------- ---------- --------- ---------- ---------DEPTNO ---------7566 JONES MANAGER 7839 02-APR-81 3075 20 7654 MARTIN 30 7698 BLAKE 30 SALESMAN MANAGER 7698 28-SEP-81 7839 01-MAY-81 1350 2950 1400

EMPNO ENAME JOB MGR HIREDATE SAL COMM ---------- ---------- --------- ---------- --------- ---------- ---------DEPTNO ---------7782 CLARK MANAGER 7839 09-JUN-81 2550 10 7788 SCOTT 20 7839 KING 10 ANALYST PRESIDENT 7566 19-APR-87 17-NOV-81 3100 5100

EMPNO ENAME JOB MGR HIREDATE SAL COMM ---------- ---------- --------- ---------- --------- ---------- ---------DEPTNO ---------7844 TURNER SALESMAN 7698 08-SEP-81 1600 0 30 7876 ADAMS 20 7900 JAMES 30 CLERK CLERK 7788 23-MAY-87 7698 03-DEC-81 1200 1050

EMPNO ENAME JOB MGR HIREDATE SAL COMM ---------- ---------- --------- ---------- --------- ---------- ---------DEPTNO ---------7902 FORD ANALYST 7566 03-DEC-81 3100 20 7934 MILLER 10 1 CLERK 7782 23-JAN-82 1400

15 rows selected. SQL> SQL>

Commit complete. SQL> SQL> SQL> set line 400; SQL> / Commit complete. SQL> select * from scott.gt2; EMPNO EPTNO -------------7369 20 7499 30 7521 30 7566 20 7654 30 7698 30 7782 10 7788 20 7839 10 7844 30 7876 20 EMPNO EPTNO -------------7900 30 7902 20 7934 10 1 ENAME JOB MGR HIREDATE SAL COMM D

---------- --------- ---------- --------- ---------- ---------- ----SMITH ALLEN WARD JONES MARTIN BLAKE CLARK SCOTT KING TURNER ADAMS ENAME CLERK SALESMAN SALESMAN MANAGER SALESMAN MANAGER MANAGER ANALYST PRESIDENT SALESMAN CLERK JOB 7902 17-DEC-80 7698 20-FEB-81 7698 22-FEB-81 7839 02-APR-81 7698 28-SEP-81 7839 01-MAY-81 7839 09-JUN-81 7566 19-APR-87 17-NOV-81 7698 08-SEP-81 7788 23-MAY-87 MGR HIREDATE 900 1700 1350 3075 1350 2950 2550 3100 5100 1600 1200 SAL COMM D 0 1400 300 500

---------- --------- ---------- --------- ---------- ---------- ----JAMES FORD MILLER CLERK ANALYST CLERK 7698 03-DEC-81 7566 03-DEC-81 7782 23-JAN-82 1050 3100 1400

15 rows selected. SQL> commit; Commit complete. SQL> select * from scott.gt2; EMPNO ENAME JOB MGR HIREDATE SAL COMM D EPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- -----

----7369 SMITH 20 7499 ALLEN 30 7521 WARD 30 7566 JONES 20 7654 MARTIN 30 7698 BLAKE 30 7782 CLARK 10 7788 SCOTT 20 7839 KING 10 7844 TURNER 30 7876 ADAMS 20 EMPNO EPTNO -------------7900 30 7902 20 7934 10 1 ENAME JOB MGR HIREDATE SAL COMM D CLERK 7788 23-MAY-87 1200 SALESMAN 7698 08-SEP-81 1600 0 PRESIDENT 17-NOV-81 5100 ANALYST 7566 19-APR-87 3100 MANAGER 7839 09-JUN-81 2550 MANAGER 7839 01-MAY-81 2950 SALESMAN 7698 28-SEP-81 1350 1400 MANAGER 7839 02-APR-81 3075 SALESMAN 7698 22-FEB-81 1350 500 SALESMAN 7698 20-FEB-81 1700 300 CLERK 7902 17-DEC-80 900

---------- --------- ---------- --------- ---------- ---------- ----JAMES FORD MILLER CLERK ANALYST CLERK 7698 03-DEC-81 7566 03-DEC-81 7782 23-JAN-82 1050 3100 1400

15 rows selected. update scott.emp set sal=sal+100 where empno=7788;<----run on scott----> select * from v$session where sid in(select blocking_session from v$session);<---rum on scott----> ALTER SYSTEM KILL SESSION '151,1717' IMMEDIATESQL <----how to kill immediate ses sion---> <----chapter 10----> deadlock update update update update scott.emp scott.emp scott.emp scott.emp set set set set sal=sal+100 sal=sal+100 sal=sal+100 sal=sal+100 where where where where empno=7788;<terminal empno=7369;<terminal empno=7788;<terminal empno=7369;<terminal 1> 2> 1> 2>

select * from dba_tables where table_name like 'GT%'

Вам также может понравиться