執行SQL發生錯誤!錯誤:no such column: def1 常見于低版本升級后
執行SQL發生錯誤!錯誤:no such column: def1 常見于低版本升級后
原因是高版本的數據庫里比低版本少連一個字段
先找到表然后添加少的字段
PbootCMS v3.0.6 版本追加了幾個新字段
Mysql
— —————————-
— Mysql數據庫升級腳本
— 適用于PbootCMS 3.0.0版本升級至3.0.6
— —————————-
—
— 新增多圖標題字段
—
ALTER TABLE ay_content ADD COLUMN picstitle varchar(1000) NOT NULL DEFAULT ”;
ALTER TABLE ay_content_sort ADD COLUMN def1 varchar(1000) NOT NULL DEFAULT ”;
ALTER TABLE ay_content_sort ADD COLUMN def2 varchar(1000) NOT NULL DEFAULT ”;
ALTER TABLE ay_content_sort ADD COLUMN def3 varchar(1000) NOT NULL DEFAULT ”;
Sqlite
— —————————-
— Sqlite數據庫升級腳本
— 適用于PbootCMS 3.0.0版本升級至3.0.6
ALTER TABLE ay_content ADD COLUMN picstitle TEXT(1000) NOT NULL DEFAULT ”;
ALTER TABLE ay_content_sort ADD COLUMN def1 TEXT(1000) NOT NULL DEFAULT ”;
ALTER TABLE ay_content_sort ADD COLUMN def2 TEXT(1000) NOT NULL DEFAULT ”;
ALTER TABLE ay_content_sort ADD COLUMN def3 TEXT(1000) NOT NULL DEFAULT ”;
DEFAULT ”;
到此問題解決。
PRAGMA foreign_keys = 0;
CREATE TABLE sqlitestudio_temp_table AS SELECT *
FROM ay_content;
PRAGMA foreign_keys = 0;
CREATE TABLE sqlitestudio_temp_table AS SELECT *
FROM ay_content;
DROP TABLE ay_content;
CREATE TABLE ay_content (
id INTEGER PRIMARY KEY AUTOINCREMENT
NOT NULL,
acode TEXT (20) NOT NULL,
scode TEXT (20) NOT NULL,
subscode TEXT (20) NOT NULL,
title TEXT (100) NOT NULL,
titlecolor TEXT (7) NOT NULL,
subtitle TEXT (100) NOT NULL,
filename TEXT (50) NOT NULL,
author TEXT (30) NOT NULL,
source TEXT (30) NOT NULL,
outlink TEXT (100) NOT NULL,
date TEXT NOT NULL,
ico TEXT (100) NOT NULL,
pics TEXT (1000) NOT NULL,
content TEXT NOT NULL,
tags TEXT (500) NOT NULL,
enclosure TEXT (100) NOT NULL,
keywords TEXT (200) NOT NULL,
description TEXT (500) NOT NULL,
sorting INTEGER (10) NOT NULL,
status TEXT (1) NOT NULL,
istop TEXT (1) NOT NULL,
isrecommend TEXT (1) NOT NULL,
isheadline TEXT (1) NOT NULL,
visits INTEGER (10) NOT NULL,
likes INTEGER (10) NOT NULL,
oppose INTEGER (10) NOT NULL,
create_user TEXT (30) NOT NULL,
update_user TEXT (20) NOT NULL,
create_time TEXT NOT NULL,
update_time TEXT NOT NULL,
gtype TEXT (1) NOT NULL
DEFAULT '4',
gid TEXT (20) NOT NULL
DEFAULT '',
gnote TEXT (100) NOT NULL
DEFAULT '',
picstitle TEXT (1000) NOT NULL
DEFAULT '',
def3 TEXT (1000) NOT NULL,
def1 TEXT (100),
def2 TEXT (1000),
picstitle TEXT (1000)
);
INSERT INTO ay_content (
id,
acode,
scode,
subscode,
title,
titlecolor,
subtitle,
filename,
author,
source,
outlink,
date,
ico,
pics,
content,
tags,
enclosure,
keywords,
description,
sorting,
status,
istop,
isrecommend,
isheadline,
visits,
likes,
oppose,
create_user,
update_user,
create_time,
update_time,
gtype,
gid,
gnote,
picstitle
)
SELECT id,
acode,
scode,
subscode,
title,
titlecolor,
subtitle,
filename,
author,
source,
outlink,
date,
ico,
pics,
content,
tags,
enclosure,
keywords,
description,
sorting,
status,
istop,
isrecommend,
isheadline,
visits,
likes,
oppose,
create_user,
update_user,
create_time,
update_time,
gtype,
gid,
gnote,
picstitle
FROM sqlitestudio_temp_table;
DROP TABLE sqlitestudio_temp_table;
CREATE INDEX ay_content_acode ON ay_content (
"acode" ASC
);
CREATE INDEX ay_content_date ON ay_content (
"date" ASC
);
CREATE INDEX ay_content_filename ON ay_content (
"filename" ASC
);
CREATE INDEX ay_content_scode ON ay_content (
"scode" ASC
);
CREATE INDEX ay_content_sorting ON ay_content (
"sorting" ASC
);
CREATE INDEX ay_content_status ON ay_content (
"status" ASC
);
CREATE INDEX ay_content_subscode ON ay_content (
"subscode" ASC
);
CREATE UNIQUE INDEX ay_content_unique ON ay_content (
sorting,
istop,
isrecommend,
isheadline,
date,
id
);
PRAGMA foreign_keys = 1;
如果您的問題還未解決可以聯系站長付費協助。

有問題可以加入技術QQ群一起交流學習
本站vip會員 請加入無憂模板網 VIP群(50604020) PS:加入時備注用戶名或昵稱
普通注冊會員或訪客 請加入無憂模板網 技術交流群(50604130)
客服微信號:15898888535
聲明:本站所有文章資源內容,如無特殊說明或標注,均為采集網絡資源。如若內容侵犯了原著者的合法權益,可聯系站長刪除。