Sqlite3常用SQL语句总结,一是防止自己忘了,二是分享

文中的SQL都是从我的项目中直接copy过来,因此很多表名什么都有了

 

//创建表

 

"CREATE TABLE FEED_TABLE(FeedID TEXT, Title TEXT, Summary TEXT, Author TEXT, ImageName VARCHAR(21), ImageType TEXT, MaxIndex INT, ImageData BLOB)"

 

 

//查询记录

 

"select * form 'table_name'"

 

"select * form 'table name' where value = '?'"

 

//插入记录

 

"INSERT INTO FEED_TABLE(FeedID, Title, Summary, ImageName, ImageType, MaxIndex) VALUES('%s', '%s', '%s', '%s', '%s', %d)"

//更新记录

 

"update 'table_name' 'column_name' = 'value'"

 

 

//删除记录

"DELETE FROM FAVORITE_TABLE WHERE EntryIndex = %d"
//删除所有记录
"delete from 'table_name'"
//删除表
"drop table 'table_name'"
//查询表结构
"select sql from sqlite_master where name = 'table_name'" 

callback的第三个参数
另外,sqlite3是支持事务的
int result; 
result = sqlite3_exec( db, "begin transaction", 0, 0, &zErrorMsg ); //开始一个事务
result = sqlite3_exec( db, "commit transaction", 0, 0, &zErrorMsg ); //提交事务
result = sqlite3_exec( db, "rollback transaction", 0, 0, &zErrorMsg ); //回滚事务

你可能感兴趣的:(sql,sqlite,table,delete,insert,callback)