简体   繁体   English

SQLiteDatabase的execSQL(String sql)函数的说明

[英]Explanation of execSQL (String sql) function of SQLiteDatabase

What does execSQL (String sql) function which belongs to SQLiteDatabase actually do? 属于SQLiteDatabase的execSQL(String sql)函数实际上做什么? i've read android documentation for it but not getting it..Please someone explain it in easy words. 我已经阅读了它的android文档,但是没有得到它。请有人用简单的词来解释它。

Thanks in advance. 提前致谢。

I know you've said you've read the Android documentation, but I'm going to link to it again as it's pretty well explained there. 我知道您已经说过您已经阅读了Android文档,但是我将再次链接到该文档,因为它在此处已得到很好的解释。 Taken from the Android documentation here 取自此处的Android文档

public void execSQL (String sql) 公共无效execSQL(字符串sql)

Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data. 执行一个不是SELECT的SQL语句或任何其他返回数据的SQL语句。

It has no means to return any data (such as the number of affected rows). 它无法返回任何数据(例如受影响的行数)。 Instead, you're encouraged to use insert(String, String, ContentValues), update(String, ContentValues, String, String[]), et al, when possible. 相反,建议您尽可能使用insert(String,String,ContentValues),update(String,ContentValues,String,String [])等。

In other words, it's used to execute any queries that don't return data, such as updating a database's tuples or inserting new tuples to the database. 换句话说,它用于执行任何不返回数据的查询,例如更新数据库的元组或向数据库中插入新的元组。

execSQL runs a single SQL query on the SQLiteDatabase and doesn't return any data. execSQL在SQLiteDatabase上运行一个SQL查询,并且不返回任何数据。 So if you wanted to insert something, or update something and didn't expect any information in return you would use this command. 因此,如果您想插入某些内容或进行更新,而又不希望得到任何信息作为回报,则可以使用此命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM