行語句的正常執行
創新互聯主營邵原網站建設的網絡公司,主營網站建設方案,成都app軟件開發,邵原h5微信小程序定制開發搭建,邵原網站營銷推廣歡迎邵原等地區企業咨詢
搭建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 < > 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 < select version(); errorcommand; select "Hello LiuMiao" as "Greetings"; select 20+22 as Result; EOF 執行結果如下所示 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$ 可以看到,缺省情況下碰到錯誤就停下來了。 WHENEVER SQLERROR 在oracle中通過WHENEVER SQLERROR來進行控制。語法如下所示 WHENEVER SQLERROR {EXIT [SUCCESS | FAILURE | WARNING | n | variable | :BindVariable] [COMMIT | ROLLBACK] | CONTINUE [COMMIT | ROLLBACK | NONE]}
當前題目:MySQL基礎:搭建bc網站sql執行錯誤時的控制方式
當前網址:http://m.jcarcd.cn/article/jecpih.html