Profile

User profile and story timeline

user-img
nyg

代码纠错:数据库id主键未设置自增,数据无法读取,id主键无法修改、不能删除记录。重建一个新表,复制内容过来,将旧表删除,更改新表名称。因为新表设置了主键自动增加,复制数据时后主键id重新自动生成。
CREATE TABLE new_postarts (
id INT AUTO_INCREMENT PRIMARY KEY,
title TEXT,
body TEXT,
body_html TEXT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
author_id INT,
cates_id INT,
FOREIGN KEY (author_id) REFERENCES users(id)
);
INSERT INTO new_postarts (title,body,body_html, timestamp,author_id, cates_id) SELECT title,body,body_html, timestamp,author_id, cates_id FROM postart;
DROP TABLE postart;
ALTER TABLE new_postarts RENAME TO postarts

回复