栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

数据库的已编译SQL语句高速缓存达到的最大大小

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

数据库的已编译SQL语句高速缓存达到的最大大小

在这里查看示例8-3和8-4 。

示例8-3 使用更新方法

public void editJob(long job_id, long employer_id, String title, String description) {    ContentValues map = new ContentValues();    map.put("employer_id", employer_id);    map.put("title", title);    map.put("description", description);    String[] whereArgs = new String[]{Long.toString(job_id)};    try{        getWritableDatabase().update("jobs", map, "_id=?", whereArgs);    } catch (SQLException e) {        Log.e("Error writing new job", e.toString());    }}

以下是示例8-3中的一些代码亮点:

例8-4显示了如何使用execSQL方法。
示例8-4 使用execSQL方法

public void editJob(long job_id, long employer_id, String title, String description) {    String sql =         "UPDATE jobs " +        "SET employer_id = ?, "+        " title = ?,  "+        " description = ? "+        "WHERe _id = ? ";    Object[] bindArgs = new Object[]{employer_id, title, description, job_id};    try{        getWritableDatabase().execSQL(sql, bindArgs);    } catch (SQLException e) {        Log.e("Error writing new job", e.toString());    }}

该消息要求您使参数使用sql变量而不是sql文字。

解析每个sql查询,生成计划,并将其存储在sql语句缓存中。

从缓存中获取具有相同文本的查询。

  --One querySELECT * FROM Customers WHERe Id = @1   (@1 = 3)SELECt * FROM Customers WHERe Id = @1   (@1 = 4)SELECt * FROM Customers WHERe Id = @1   (@1 = 5)

在缓存中找不到具有不同文本(包括文字)的查询,并已(无用地)将查询添加到了该查询中。

  --Three Queries.SELECt * FROM Customers WHERe Id = 3SELECt * FROM Customers WHERe Id = 4SELECt * FROM Customers WHERe Id = 5


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/392597.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号