国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

MySQL基礎 創建bc網站sql執行錯誤時的控制方式

2024-07-24 12:32:12
字體:
來源:轉載
供稿:網友
        行語句的正常執行
 
       搭建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]}

(編輯:武林網)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南召县| 青阳县| 玉林市| 雷州市| 琼海市| 文安县| 高要市| 华容县| 平定县| 林口县| 神农架林区| 南部县| 靖州| 遂溪县| 抚宁县| 阳江市| 临湘市| 霸州市| 拉萨市| 洛宁县| 宜川县| 石台县| 岑巩县| 隆安县| 库伦旗| 龙江县| 祁阳县| 湘潭县| 邵武市| 上虞市| 安阳县| 搜索| 久治县| 仁化县| 谷城县| 武山县| 禹城市| 乐亭县| 元朗区| 丘北县| 汉源县|