zoukankan      html  css  js  c++  java
  • iOS-SQLite(FMDB)

    在已经存在的表中,添加字段,更新表结构

    /** Test to see if particular column exists for particular table in database
     
     @param columnName The name of the column.
     
     @param tableName The name of the table.
     
     @return `YES` if column exists in table in question; `NO` otherwise.
     */
    
    - (BOOL)columnExists:(NSString*)columnName inTableWithName:(NSString*)tableName;
    

    举例说明

        
        // 在 testTable 中,添加 name 字段
        [_dbQueue inDatabase:^(FMDatabase *db) {
    
            NSString *createTable = [NSString stringWithFormat:@"create table if not exists testTable (sessionId text primary key not null, wds text);"];
            
            BOOL rezult = [db executeUpdate:createTable];
            
            if (![db columnExists:@"name" inTableWithName:@"testTable"]){
                NSString * Show_Notice = [NSString stringWithFormat:@"ALTER TABLE testTable ADD COLUMN name text;"];
                [db executeUpdate:Show_Notice];
            }
        }];
    
    
  • 相关阅读:
    类加载,初始化
    jvm classLoader architecture
    只选择年份的下拉菜单
    spring框架学习(二)依赖注入
    spring框架学习(一)
    JSP 过滤器
    JSP9个内置对象
    JSP 动作元素
    众数
    基于excel9.h的excel处理
  • 原文地址:https://www.cnblogs.com/ShaoYinling/p/6811574.html
Copyright © 2011-2022 走看看