执行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
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若内容侵犯了原著者的合法权益,可联系站长删除。