1. 程式人生 > >shell指令碼判斷hive表是否存在

shell指令碼判斷hive表是否存在

#!/bin/bash
#日誌目錄
#shell判斷表hive表是否存在
#TABLE=庫名.表名
TABLE=dal.dal_mdn_communication_behavior
hive -e"
     desc $TABLE;
" 2>&1 | grep 'Table not found'
rtstatus=$?
echo $rtstatus
if [ $rtstatus -ne 0 ]; then
    echo "hbase表已存在!"
else
   echo "hbase表不存在!"
fi

以上內容,僅作為自己學習使用