SQL语法错误抛出“ CLUSTERED”附近:语法错误

时间:2018-10-08 06:28:21

标签: ios sql swift sqlite opaque-pointers

在加载sql查询其抛出错误时

“聚集”附近:语法错误

import SQLite3
var db: OpaquePointer?
let fileURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
            .appendingPathComponent("HeroesDatabase.sqlite")
        if sqlite3_open(fileURL.path, &db) != SQLITE_OK {
            print("error opening database")
        }
        let sqlString = """
            CREATE TABLE Dim_Date
        (Calendar_Date DATE NOT NULL CONSTRAINT PK_Dim_Date PRIMARY KEY CLUSTERED,Calendar_Date_String VARCHAR(10) NOT NULL)
        """


 if sqlite3_exec(db, sqlString, nil, nil, nil) != SQLITE_OK {
            let errmsg = String(cString: sqlite3_errmsg(db)!)
            print("error creating table: \(errmsg)")//Here Error throws
        }

实际上,我正在努力实现这一https://www.sqlshack.com/designing-a-calendar-table/

0 个答案:

没有答案