我的数据库中有这样一个表(用于游戏):
id name playcount
---- ------ -----------
1 game#1 17
2 game#2 22
等等,并且字段 playcount 具有属性DEFAULT 0;
所以,假设我想通过导出除 playcount 之外的所有字段来重新创建这个数据库。
我怎样才能做到这一点?一个 phpmyadmin 解决方案是可以的。谢谢 !
您可以使用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 语法
LOAD DATA INFILE 'backup.txt'
INTO TABLE TableName
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';