-
Notifications
You must be signed in to change notification settings - Fork 38
Working with Tables
ziminji edited this page Oct 23, 2011
·
12 revisions
CREATE TABLE Customer (pk INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(35));
// Creates the SQL statement
ZIMSqlCreateTableStatement *create = [[ZIMSqlCreateTableStatement alloc] init];
[create table: @"Customer"];
[create column: @"pk" type: ZIMSqlDataTypeInteger defaultValue: ZIMSqlDefaultValueIsAutoIncremented];
[create column: @"name" type: ZIMSqlDataTypeVarChar(35)];
NSString *statement = [create statement];
NSLog(@"%@", statement);
// Executes the SQL statement
NSNumber *result = [ZIMDbConnection dataSource: @"live" execute: statement];
DROP TABLE Customer;
// Creates the SQL statement
ZIMSqlDropTableStatement *drop = [[ZIMSqlDropTableStatement alloc] init];
[drop table: @"Customer"];
NSString *statement = [drop statement];
NSLog(@"%@", statement);
// Executes the SQL statement
NSNumber *result = [ZIMDbConnection dataSource: @"live" execute: statement];