我已为sql
,cities
&转储regions
表格countries
。
我的本地计算机中有.sql
个文件。我需要将它们转换为CSV
格式。
所以我有两个问题。
1):这样做的最佳方式是什么?我可以使用任何工具吗? (我有一台Mac)
2):
我found this site。所以我尝试了这段代码:
CREATE TABLE IF NOT EXISTS `countries` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`code` varchar(10) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=231 DEFAULT CHARSET=latin1;
-- Dumping data for table dddblog.countries: ~218 rows (approximately)
/*!40000 ALTER TABLE `countries` DISABLE KEYS */;
INSERT INTO `countries` (`id`, `name`, `code`) VALUES
(1, 'Andorra', 'ad'),
(2, 'United Arab Emirates', 'ae'),
(3, 'Afghanistan', 'af'),
(4, 'Antigua and Barbuda', 'ag'),
(5, 'Anguilla', 'ai'),
(6, 'Albania', 'al'),
(7, 'Armenia', 'am'),
(8, 'Netherlands Antilles', 'an'),
(9, 'Angola', 'ao'),
// Other countries
/*!40000 ALTER TABLE `countries` ENABLE KEYS */;
当我点击转换时,我收到错误:Missing SELECT STATEMENT
。
我不熟悉SQL,感谢任何帮助!
答案 0 :(得分:0)
消息Missing SELECT STATEMENT
说明了一切:您必须添加SELECT
声明。
尝试使用此代码 - 为我工作:
CREATE TABLE IF NOT EXISTS `countries` (
`id` smallint(5) NOT NULL ,
`name` varchar(255) NOT NULL,
`code` varchar(10) NOT NULL
);
INSERT INTO `countries` (`id`, `name`, `code`) VALUES
(1, 'Andorra', 'ad'),
(2, 'United Arab Emirates', 'ae'),
(3, 'Afghanistan', 'af'),
(4, 'Antigua and Barbuda', 'ag'),
(5, 'Anguilla', 'ai'),
(6, 'Albania', 'al'),
(7, 'Armenia', 'am'),
(8, 'Netherlands Antilles', 'an'),
(9, 'Angola', 'ao')
;
SELECT `id`, `name`, `code` FROM `countries`