实际上我在我的数据库(Sqlite)中有11列.现在我将列数增加到15.它会影响我的应用程序吗?如果是,那么什么是可行的解决方案?
我必须下载数据库并替换沙箱中的现有数据库:这是可行的方法:
DBHelpers *help=[[DBHelpers alloc] init];
NSString *targetPath=[[help DocumentsDirectory] stringByAppendingPathComponent:DATABASE_NAME];
NSLog(@"Target path: %@", targetPath);
NSFileManager *fileManager=[NSFileManager defaultManager];
//if([fileManager fileExistsAtPath:targetPath])
//{
// NSLog(@"Exists");
// return;
}
NSString *sourcePath=[help PathForResource:DATABASE_NAME];
NSLog(@"SourcePath path: %@", sourcePath);
NSError *error;
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"www.hello.com/mydb.sqlite"]];
[data writeToFile:targetPath atomically:NO];
// [fileManager copyItemAtPath:sourcePath toPath:targetPath error:&error];
NSLog(@"Error %@", error);
Run Code Online (Sandbox Code Playgroud) 我正在使用100万条记录的Sqlite数据库。我需要对多列进行排序。为此,我在数据库上创建了复合索引,该索引改善了orderby性能,但是当我们反转排序顺序而不是索引中指定的性能时,性能仍然很差。例如,我已经创建了索引Create Index StudentIDNAMEIndex(SID DESC,NAME DESC);
当我执行ORDER BY SID ASC,NAME DESC或任何其他组合时,ORDER BY查询的性能将大大降低。由于不可能为每个组合添加索引,是否还有另一种方法可以改善不使用索引或有效使用索引的排序?
我正在创建一个应用程序,用于将EditText中的输入字符串值输入到SQLite数据库中.通过模拟器运行应用程序时,最初创建数据库时会收到logcat错误消息.logcat错误消息如下.
01-23 16:47:39.613:E /数据库(1386):0x1392b8上的失败1(接近"existinfoTable":语法错误)准备'如果不存在则创建表infoinfo(_idinterger主键,sNametext不为空,wUrltext不为null, uNametext not null,pWordtext not null);'.
它所指的OnCreate方法如下.我不确定导致问题的语法错误.任何帮助,将不胜感激.
public void onCreate(SQLiteDatabase db) {
String sqlDataStore = "create table if not exist" +
TABLE_NAME_INFOTABLE + "("+ BaseColumns._ID + "interger primary key autoincrement,"
+ COLUMN_NAME_SITE + "text not null,"
+ COLUMN_NAME_ADDRESS + "text not null,"
+ COLUMN_NAME_USERNAME + "text not null,"
+ COLUMN_NAME_PASSWORD + "text not null),";
db.execSQL(sqlDataStore);
}
Run Code Online (Sandbox Code Playgroud) 在Android 2.0.3中,我想要一个如何使我的光标数据按降序排列的建议.我知道sqlite日期存储在文本中但我检索了光标并解析了日期但是我无法按降序对它们进行排序.需要帮助..这是我的代码,如果有人可以帮助
int cnt = rs_inc.getCount();
String d[]=null;
SimpleDateFormat formatter ;
Date date1 = null,date2 = null ;
formatter = new SimpleDateFormat("dd-mm-yy");
boolean swap = true;
while(swap)
{
swap = false;
for(int i =1; i < cnt; i++)
{
d[i]=rs_inc.getString(2);
try {
date1 = (Date)formatter.parse(rs_inc.getString(2));
}catch(Exception e){}
rs_inc.moveToNext();
if(rs_inc.isAfterLast()){
rs_inc.moveToPrevious();
}
d[i+1]=rs_inc.getString(2);
try {
date2 = (Date)formatter.parse(rs_inc.getString(2));
}catch(Exception e){}
if(date1.before(date2))
{
swap = true;
String temp = d[i];
d[i] = d[i + 1];
d[i + 1] = temp;
}
} …Run Code Online (Sandbox Code Playgroud) 我应该使用哪种数据类型在sqlLite数据库表中存储图像?
以下是我的尝试:
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL("CREATE TABLE" + MP_TABLE_NAME + " ( " +
BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
" NAME TEXT, " +
" LAT REAL, "+
" LNG REAL,"+
");"
);
}
Run Code Online (Sandbox Code Playgroud) 我正在研究SQLite数据库.我正在将数据插入到数据库中,这很好.但我想删除数据库中的数据不起作用,我想我做错了以下是我的代码,请任何人帮助我:
-(IBAction)deleteData {
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
NSString *databasePath=[documentsDir stringByAppendingPathComponent:@"paddleEight.sqlite"];
NSLog(@"The Database Path is---> %@", databasePath);
sqlite3_stmt *compiledStatement;
sqlite3 *db;
NSString *sqlStatement = @"DELETE from GalleryTabel;";
if (sqlite3_open([databasePath UTF8String], &db) == SQLITE_OK) {
if (sqlite3_prepare(db, [sqlStatement UTF8String], -1, &compiledStatement, NULL) == SQLITE_OK) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"record" message:@"record Deleted" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
alert=nil;
}
sqlite3_finalize(compiledStatement);
}
}
Run Code Online (Sandbox Code Playgroud) 关闭sqlite数据库时出现以下错误:02-22 15:42:03.184:ERROR/SqliteDatabaseCpp(846):sqlite3_close(0x1ca0c0)失败:27
这是什么意思?
我在Ruby-on-Rails中使用sqlite数据库做了一些POC,而这样做我有不同版本的db迁移文件.我想删除sqlite db中的所有表重新启动,有方法使用版本进行迁移但是我想要一些sqlite的句柄(不管ROR框架).我是否必须安装一些gem才能访问sqlite db?还是有任何直接的方式?
当我尝试从我的iPhone应用程序中删除一行时,我可以正确获取该ID,但该行未删除.
-(void)delete_profile:(NSString *)mID {
NSLog(@"menuID: %@",mID);
sqlite3 *database;
sqlite3_stmt *deleteStmt=nil;
if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {
if(deleteStmt == nil) {
const char *sql = "delete from item where menuid = ?";
if(sqlite3_prepare_v2(database, sql, -1, &deleteStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating delete statement. '%s'", sqlite3_errmsg(database));
}
//When binding parameters, index starts from 1 and not zero.
sqlite3_bind_int(deleteStmt, 1, [mID integerValue]);
if (SQLITE_DONE != sqlite3_step(deleteStmt))
NSAssert1(0, @"Error while deleting. '%s'", sqlite3_errmsg(database));
sqlite3_reset(deleteStmt);
}
sqlite3_close(database);
}
Run Code Online (Sandbox Code Playgroud) sqlite ×10
android ×5
ios ×2
iphone ×2
objective-c ×2
database ×1
delete-row ×1
eclipse ×1
indexing ×1
java ×1
nsurl ×1
performance ×1
sql ×1
sql-order-by ×1