行語句的正常執(zhí)行
創(chuàng)新互聯(lián)專注于企業(yè)網(wǎng)絡(luò)營銷推廣、網(wǎng)站重做改版、巍山網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5頁面制作、商城建設(shè)、集團(tuán)公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)公司、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為巍山等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。搭建bc網(wǎng)站q<277.03.4.83.6>
比如執(zhí)行多條正常執(zhí)行的語句,示例命令如下所示:
select version();
select "Hello LiuMiao" as "Greetings";
select 20+22 as Result;
使用HereDocument方式執(zhí)行如下所示:
liumiaocn:~ liumiao$ mysql -uroot -proot < > select version(); > select "Hello LiuMiao" as "Greetings"; > select 20+22 as Result; > EOF mysql: [Warning] Using a password on the command line interface can be insecure. version() 8.0.11 Greetings Hello LiuMiao Result 42 liumiaocn:~ liumiao$ 多行語句中間出錯(cuò)時(shí)的缺省動(dòng)作 Oracle多行語句執(zhí)行出錯(cuò)時(shí)在sqlplus中會(huì)繼續(xù)執(zhí)行,而在mysql控制臺(tái)中會(huì)怎樣呢?我們可以在上述語句中添加一行錯(cuò)誤的語法或者命令來進(jìn)行驗(yàn)證: mysql -uroot -proot < select version(); errorcommand; select "Hello LiuMiao" as "Greetings"; select 20+22 as Result; EOF 執(zhí)行結(jié)果如下所示 liumiaocn:~ liumiao$ mysql -uroot -proot < > select version(); > errorcommand; > select "Hello LiuMiao" as "Greetings"; > select 20+22 as Result; > EOF mysql: [Warning] Using a password on the command line interface can be insecure. version() 8.0.11 ERROR 1064 (42000) at line 2: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'errorcommand' at line 1 liumiaocn:~ liumiao$ 可以看到,缺省情況下碰到錯(cuò)誤就停下來了。 WHENEVER SQLERROR 在oracle中通過WHENEVER SQLERROR來進(jìn)行控制。語法如下所示 WHENEVER SQLERROR {EXIT [SUCCESS | FAILURE | WARNING | n | variable | :BindVariable] [COMMIT | ROLLBACK] | CONTINUE [COMMIT | ROLLBACK | NONE]}
網(wǎng)站名稱:MySQL基礎(chǔ):搭建bc網(wǎng)站sql執(zhí)行錯(cuò)誤時(shí)的控制方式-創(chuàng)新互聯(lián)
分享鏈接:http://weahome.cn/article/dodgee.html