oracle 查询表的主键
查询主键
SELECT UIC.COLUMN_NAME
FROM USER_IND_COLUMNS UIC, USER_CONSTRAINTS UC
WHERE UC.CONSTRAINT_TYPE = 'P'
AND UC.TABLE_NAME = UIC.TABLE_NAME
AND UC.TABLE_NAME = 'XXXXXXX' AND UIC.INDEX_NAME LIKE '%_PK' ORDER BY UIC.TABLE_NAME, UIC.COLUMN_POSITION
创建主键
ALTER TABLE 'XXXXXXX'
ADD (CONSTRAINT XXXXXXX_PK
PRIMARY KEY (XXX_NO) using index tablespace XXXXXXXXX);
查询锁 杀死进程
1.通过上句查找出已被锁定的数据库表及相关的sid、serial#及spid select object_name as 对象名称,s.sid,s.serial#,p.spid as 系统进程号 from v$locked_object l , dba_objects o , v$session s , v$process p where l.object_id=o.object_id and l.session_id=s.sid and s.paddr=p.addr;
2.在数据库中灭掉相关session alter system kill session 'sid,serial#';--sid及serial#为第一步查出来的数据。
BY:www.btbear.net