MySQL高級(jí) 第7章批量數(shù)據(jù)腳本
1. 插入數(shù)據(jù)
1.1 建表語句
1.2 設(shè)置參數(shù)
在執(zhí)行創(chuàng)建函數(shù)之前,首先請(qǐng)保證log_bin_trust_function_creators參數(shù)為1,即on開啟狀態(tài)。
否則會(huì)報(bào)錯(cuò):
查詢:show variables like 'log_bin_trust_function_creators';
設(shè)置:set global log_bin_trust_function_creators=1;
當(dāng)然,如上設(shè)置只存在于當(dāng)前操作,想要永久生效,需要寫入到配置文件中:
在[mysqld]中加上log_bin_trust_function_creators=1
1.3 編寫隨機(jī)函數(shù)
創(chuàng)建函數(shù),保證每條數(shù)據(jù)都不同.
1.3.1 隨機(jī)產(chǎn)生字符串
如果要?jiǎng)h除函數(shù),則執(zhí)行:drop function rand_string;
1.3.2 隨機(jī)產(chǎn)生部門編
1.4 創(chuàng)建存儲(chǔ)過程
1.4.1 創(chuàng)建往emp表中插入數(shù)據(jù)的存儲(chǔ)過程

1.4.2 創(chuàng)建往dept表中插入數(shù)據(jù)的存儲(chǔ)過程


1.6 批量刪除某個(gè)表上的所有索引
1.6.1 刪除索引的存儲(chǔ)過程

1.6.2 執(zhí)行存儲(chǔ)過程
調(diào)用:CALL proc_drop_index("dbname","tablename");