使用列约束时 CREATE 语句中的未知错误
Unknown error in CREATE statement when using column constraint
我正在尝试使用 .NET Framework 4.7.2
下的 System.Data.SQLite
库和语句
创建 SQLite
table
CREATE TABLE IF NOT EXISTS account_accessibility (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL DEFAULT 'lk3' CHECK (name IN ('lk3', 'api', 'err')),
created TEXT NOT NULL DEFAULT datetime('now'),
notified INTEGER NOT NULL DEFAULT 0 CHECK (notified IN (0, 1)),
closed TEXT,
id_sm TEXT
);
出现错误:
SQL logic error
near "(": syntax error
如何解决这个问题? SQLite
版本:3.32.1.
使用 with 表达式时应使用带括号的 DEFAULT 运算符:
CREATE TABLE IF NOT EXISTS account_accessibility (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL DEFAULT 'lk3' CHECK (name IN ('lk3', 'api', 'err')),
created TEXT NOT NULL DEFAULT (datetime('now')),
notified INTEGER NOT NULL DEFAULT 0 CHECK (notified IN (0, 1)),
closed TEXT,
id_sm TEXT
);
我正在尝试使用 .NET Framework 4.7.2
下的 System.Data.SQLite
库和语句
SQLite
table
CREATE TABLE IF NOT EXISTS account_accessibility (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL DEFAULT 'lk3' CHECK (name IN ('lk3', 'api', 'err')),
created TEXT NOT NULL DEFAULT datetime('now'),
notified INTEGER NOT NULL DEFAULT 0 CHECK (notified IN (0, 1)),
closed TEXT,
id_sm TEXT
);
出现错误:
SQL logic error near "(": syntax error
如何解决这个问题? SQLite
版本:3.32.1.
使用 with 表达式时应使用带括号的 DEFAULT 运算符:
CREATE TABLE IF NOT EXISTS account_accessibility (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL DEFAULT 'lk3' CHECK (name IN ('lk3', 'api', 'err')),
created TEXT NOT NULL DEFAULT (datetime('now')),
notified INTEGER NOT NULL DEFAULT 0 CHECK (notified IN (0, 1)),
closed TEXT,
id_sm TEXT
);