ORACLE query process, and kill

Used to store commonly used SQL

- Query the primary key column in which 
SET pageSize 20 is   - Sets the page size 
SET LINESIZE 120  - set the line size 
COL COLUMN_NAME for A20 - setting a length field displays 
COL TABLE_NAME for A20 
COL OWNER for A20 
COL CONSTRAINT_NAME for A20 

SELECT cons.owner, cons.constraint_name, cons.table_name, cons.column_name 
 from ALL_CONS_COLUMNS cons, ALL_CONSTRAINTS INTS
 WHERE cons.constraint_name = ints.constraint_name
 and ints.table_name = 'TABLE_NAME '  and ints.constraint_type = ' P ' ; 

- see Table locked 
SELECT . B.owner, B object_name , a.session_id, a.locked_mode from V $ locked_object A, B dba_objects WHERE B. Object_id  = A. Object_id ; 

- Check that the user that the process according to deadlock 
the SELECT b.username, b.sid, b.serial #, LOGON_TIME from v $ locked_object A, v $ b the session the WHERE a.session_id = b.sid the Order  by b.logon_time ; 

- process Viewer connections 
SELECTsid, Serial #, username, OSUSER the FROM v $ the session; 

- 3. found locked tables sid, serial #, os_user_name, machine_name , terminal, lock of the type, the MODE 
the SELECT s.sid, s.serial #, S. username, s.schemaname, s.osuser, s.process, s.machine, 
s.terminal, s.logon_time, l.type 
the FROM V $ the session S, V $ L Lock
 the WHERE s.sid = l.sid
 the AND S. username iS  the NOT  NULL 
the ORDER  BY sid;
 / * this statement will look to lock the database of all the DML statements generated, can also be found, 
any DML statements actually had two locks, one lock table, a row lock. * / 

- kill the process sid, Serial # 
the ALTER System the kill the session '210,11562';

 

Guess you like

Origin www.cnblogs.com/yangsy/p/oracle_yh.html