当前位置: 代码迷 >> SQL >> SQL判断一个表在系统中是不是存在
  详细解决方案

SQL判断一个表在系统中是不是存在

热度:26   发布时间:2016-05-05 13:22:15.0
SQL判断一个表在系统中是否存在
/**     * 判断某张表是否存在     * @param tabName 表名     * @return     */    public boolean tabbleIsExist(String tableName){            boolean result = false;            if(tableName == null){                    return false;            }            SQLiteDatabase db = null;            Cursor cursor = null;            try {                    db = this.getReadableDatabase();                    String sql = "select count(*) as c from "+AppConstant.DataBaseName+" where type =''table'' and name =''"+tableName.trim()+"'' ";                    cursor = db.rawQuery(sql, null);                    if(cursor.moveToNext()){                            int count = cursor.getInt(0);                            if(count>0){                                    result = true;                            }                    }                                } catch (Exception e) {                    // TODO: handle exception            }                           return result;    }

?以上就可以用来判断一个表是否在系统中存在了!

  相关解决方案