幾個實用的mysql指令碼

2021-09-25 15:44:11 字數 1551 閱讀 7259

1、修改資料庫中所有表的某個同名字段列

create  procedure `儲存過程名`()

begin

-- 定義迴圈條件

declare flag int default 0;

-- 儲存表名

declare tname varchar(50);

-- 查詢資料庫super_star中含有school_code列的表,如果區分大小寫使用binary column_name = 'school_code'

declare result cursor for select table_name from information_schema.columns where table_schema = '資料庫' and table_name like '表';

-- 退出迴圈

declare continue handler for sqlstate '02000' set flag = 1;

-- 開啟游標

open result;

while flag <> 1 do

-- 游標指向下乙個位置,可以有多個資料,比如fetch result into tname,ttype,...;

fetch result into tname;

-- 拼接字串表名sql,根據需要使用concat函式連線

-- set @execsql = concat('select * from ',tname,' where school_code = ',oldimei,' ;');

set @execsql = concat("update ",tname," set 字段 = '3636000538'");

-- set @execsql = concat("delete from ",tname);

prepare stmt from @execsql;

execute stmt;

end while;

end

2、表和字段查詢

-- 查詢有資料的表

select table_name from information_schema.tables

where table_rows>0 and table_name like '表名';

-- 根據表名查表

select table_name, table_comment from information_schema.tables

where table_schema='資料庫' and table_type='base table'

and table_comment like '表名'

-- 根據表查字段

select column_name 字段編碼,column_comment 欄位名稱

from information_schema.columns

where table_schema='資料庫' and table_name = '表名'

and column_name='欄位名';

python實用的幾個指令碼程式(自己在用)

2.label的重建 本文主要是自己近期在做畢業設計 連續手語識別 時候寫的幾個python指令碼,用於處理資料集的。記錄一下。本文撰寫採用windows作業系統,如果是linux記得修改字串分割方式及目錄層數多加一層。def getlabeldict labelfile f codecs.open...

幾個實用的linux命令

檢視當前登入的賬戶 who am ifree 顯示記憶體狀態用法 free m s m 表示記憶體的狀態用 m 為單位來表示,s 表示重新整理的時間間隔,秒為單位 示例 free m s 3mount a a mount allfilesystems of the given types menti...

10 實用指令碼

1.1perl perl pi.bak e s aa bb g file p 隱式迴圈遍歷指定的檔案 i.bak i為原位編輯,即直接修改檔案內容,bak是備份成bak字尾的檔案 如果想對特定的檔案進行修改,可以 find name sv xargs perl pi.bak e s aa bb g ...