用戶需求要為一個table增加一個欄位,SQL語句如下:
alter table btd_file add btd14b decimal(15,5) not null before btd15b;
結果出現 106: ISAM 錯誤: 非獨佔性存取.
有用戶在使用,無法對表結構進行修改.
於是就想辦法找出誰在使用,先kick掉吧,急件處理表結構問題.
1.查找使用該表的所有sessionid:
select sqx_sessionid from syssqexplain
where sqx_sqlstatement matches '*btd_file*';
sqx_sessionid
1511047
查詢到1列。
2.查找user:
chnhsyt</u/infoth>$onstat -u|grep 1511047
c000000036ca2cf0 Y--P--- 1510786 HAN03942tib c0000000424b99b8 0 3 0 0
3.殺掉session:
chnhsyt</u/infoth>$onmode -z 1511047
最後,重新對表結構進行修改即可OK.
附:syssqexplain系統表結構
create table "sysmaster".syssqexpalin {用户查询}
(
sqx_sessionid integer, {SQL语句的对话ID,匹配onstat -u 输出}
sqx_bufreads integer, {SQL语句完成的缓冲区读次数}
sqx_pagereads integer, {SQL语句完成的页面读次数}
sqx_totsorts integer, {SQL语句完成的排序次数}
sqx_estcost integer, {这个查询的估计成本,应与SET EXPLAIN的输出相同。注:这个成本有时偏高,但可以作为寻找坏查询的参考}
sqx_estrows integer, {检查这个查询返回的行,应与SET EXPALIN的输出相同}
sqx_seqscan smallint,{查询是顺序表格扫描时返回1,通常表示有问题}
sqx_srtscan smallint,{查询是排序扫描时返回1}
sqx_autoindex smallint,{查询是表格自动索引时返回1}
sqx_mrgjoin smallint,{查询是合并连接时返回1}
sqx_dynhashjoin smallint,{查询是动态散列连接时返回1 }
sqx_sqlstatement char(32000){SQL语句文本}
);