我的数据库中有这样一个表(用于游戏):
id name playcount
---- ------ -----------
1 game#1 17
2 game#2 22
等,字段playcount具有属性DEFAULT 0;
所以,我想通过导出除playcount之外的所有字段来重新创建这个数据库。
我该怎么做?一个phpmyadmin解决方案没问题。谢谢!
答案 0 :(得分:0)
您可以对此使用INTO OUTFILE
,以生成CSV
格式
SELECT id, name, 0 AS playcount
INTO OUTFILE 'backup.txt' -- this is the location
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM TableName;
要重新加载文件,请使用LOAD DATA INFILE Syntax
LOAD DATA INFILE 'backup.txt'
INTO TABLE TableName
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';