您好,登錄后才能下訂單哦!
行語句的正常執行
搭建bc網站q<277.03.4.83.6>
比如執行多條正常執行的語句,示例命令如下所示:
select version();
select "Hello LiuMiao" as "Greetings";
select 20+22 as Result;
使用HereDocument方式執行如下所示:
liumiaocn:~ liumiao$ mysql -uroot -proot <<EOF
> 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$
多行語句中間出錯時的缺省動作
Oracle多行語句執行出錯時在sqlplus中會繼續執行,而在mysql控制臺中會怎樣呢?我們可以在上述語句中添加一行錯誤的語法或者命令來進行驗證:
mysql -uroot -proot <<EOF
select version();
errorcommand;
select "Hello LiuMiao" as "Greetings";
select 20+22 as Result;
EOF
執行結果如下所示
liumiaocn:~ liumiao$ mysql -uroot -proot <<EOF
> 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$
可以看到,缺省情況下碰到錯誤就停下來了。
WHENEVER SQLERROR
在oracle中通過WHENEVER SQLERROR來進行控制。語法如下所示
WHENEVER SQLERROR {EXIT [SUCCESS | FAILURE | WARNING | n | variable | :BindVariable] [COMMIT | ROLLBACK] | CONTINUE [COMMIT | ROLLBACK | NONE]}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。