我正在尝试在Filemaker中使用此查询 - > MySQL转换脚本。表创建步骤直接从phpMyAdmin导出,我在DROP语句中添加。
DROP TABLE IF EXISTS artifacts; CREATE TABLE IF NOT EXISTS `artifacts` ( `aid` INT(11) UNSIGNED NOT NULL auto_increment, `accession number` TEXT NOT NULL, `name` TEXT NOT NULL, `period 1` TEXT NOT NULL, `period 3 date` TEXT NOT NULL, `visual description` TEXT NOT NULL, `religion 1` TEXT NOT NULL, `dimen 1 number` DECIMAL(10, 2) NOT NULL, `dimen 2 number` DECIMAL(10, 2) NOT NULL, `dimen 3 number` DECIMAL(10, 2) NOT NULL, `dimen 1 type` TEXT NOT NULL, `dimen 2 type` TEXT NOT NULL, `dimen 3 type` TEXT NOT NULL, `materials 2` TEXT NOT NULL, `manufacturing processes 2` TEXT NOT NULL, `weight` INT(11) NOT NULL, `measuring remarks` TEXT NOT NULL, `munsell color information` TEXT NOT NULL, `reproduction` TEXT NOT NULL, `reproduction notes` TEXT NOT NULL, `published description` TEXT NOT NULL, `scholarly notes` TEXT NOT NULL, `bibliography` TEXT NOT NULL, `comparanda` TEXT NOT NULL, `exhibit label` TEXT NOT NULL, `artist` TEXT NOT NULL, `spurlock loc 3` TEXT NOT NULL, `archaeological data` TEXT NOT NULL, `credit line` TEXT NOT NULL, `provenance` TEXT NOT NULL, `museum dedication` TEXT NOT NULL, `spurlock status` TEXT NOT NULL, `public description` TEXT NOT NULL, `working set 5 wb` TEXT NOT NULL, `image source` TEXT NOT NULL, `cm mec ma` TEXT NOT NULL, `webprivate` TEXT NOT NULL, `spurlock loc 2` TEXT NOT NULL, `hiresimagecheck` TEXT NOT NULL, PRIMARY KEY (`aid`), FULLTEXT KEY `name` (`name`), FULLTEXT KEY `accession number` (`accession number`, `name`, `period 1`, `visual description`, `materials 2`, `published description`, `artist`, `credit line`), FULLTEXT KEY `accession number_2` (`accession number`), FULLTEXT KEY `visual description` (`visual description`), FULLTEXT KEY `published description` (`published description`) ) engine=myisam DEFAULT charset=latin1 auto_increment=1; DROP TABLE IF EXISTS culture; CREATE TABLE IF NOT EXISTS `culture` ( `cid` INT(10) UNSIGNED NOT NULL auto_increment, `culture` VARCHAR(255) NOT NULL, PRIMARY KEY (`cid`), UNIQUE KEY `culture` (`culture`) ) engine=myisam DEFAULT charset=latin1 auto_increment=1; DROP TABLE IF EXISTS geocity; CREATE TABLE IF NOT EXISTS `geocity` ( `gid` INT(10) UNSIGNED NOT NULL auto_increment, `city` VARCHAR(255) NOT NULL, PRIMARY KEY (`gid`), UNIQUE KEY `city` (`city`) ) engine=myisam DEFAULT charset=latin1 auto_increment=1; DROP TABLE IF EXISTS geocontinent; CREATE TABLE IF NOT EXISTS `geocontinent` ( `gid` INT(10) UNSIGNED NOT NULL auto_increment, `continent` VARCHAR(255) NOT NULL, PRIMARY KEY (`gid`), UNIQUE KEY `continent` (`continent`) ) engine=myisam DEFAULT charset=latin1 auto_increment=1; DROP TABLE IF EXISTS geocountry; CREATE TABLE IF NOT EXISTS `geocountry` ( `gid` INT(10) UNSIGNED NOT NULL auto_increment, `country` VARCHAR(255) NOT NULL, PRIMARY KEY (`gid`), UNIQUE KEY `country` (`country`) ) engine=myisam DEFAULT charset=latin1 auto_increment=1; DROP TABLE IF EXISTS geolocality; CREATE TABLE IF NOT EXISTS `geolocality` ( `gid` INT(10) UNSIGNED NOT NULL auto_increment, `locality` VARCHAR(255) NOT NULL, PRIMARY KEY (`gid`), UNIQUE KEY `locality` (`locality`) ) engine=myisam DEFAULT charset=latin1 auto_increment=1; DROP TABLE IF EXISTS georegion; CREATE TABLE IF NOT EXISTS `georegion` ( `gid` INT(10) UNSIGNED NOT NULL auto_increment, `region` VARCHAR(255) NOT NULL, PRIMARY KEY (`gid`), UNIQUE KEY `region` (`region`) ) engine=myisam DEFAULT charset=latin1 auto_increment=1; DROP TABLE IF EXISTS nomcategory; CREATE TABLE IF NOT EXISTS `nomcategory` ( `nid` INT(10) UNSIGNED NOT NULL auto_increment, `category` VARCHAR(255) NOT NULL, PRIMARY KEY (`nid`), UNIQUE KEY `category` (`category`) ) engine=myisam DEFAULT charset=latin1 auto_increment=1; DROP TABLE IF EXISTS nomclassification; CREATE TABLE IF NOT EXISTS `nomclassification` ( `nid` INT(10) UNSIGNED NOT NULL auto_increment, `classification` VARCHAR(255) NOT NULL, PRIMARY KEY (`nid`), UNIQUE KEY `classification` (`classification`) ) engine=myisam DEFAULT charset=latin1 auto_increment=1; DROP TABLE IF EXISTS nomsubclassification; CREATE TABLE IF NOT EXISTS `nomsubclassification` ( `nid` INT(10) UNSIGNED NOT NULL auto_increment, `subclassification` VARCHAR(255) NOT NULL, PRIMARY KEY (`nid`), UNIQUE KEY `subclassification` (`subclassification`) ) engine=myisam DEFAULT charset=latin1 auto_increment=1;
但是,当我尝试执行此查询时,我得到:
MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE IF NOT EXISTS `artifacts` ( `aid` IN' at line 3
语法对我来说都很好,有人能发现错误吗?我使用的唯一SQL格式化程序报告没有错误。
答案 0 :(得分:7)
你的脚本运行正常。问题是您执行它的方式(客户端希望通过查询查询而不是整个脚本)或者您已将分隔符更改为除;
之外的其他内容
DELIMITER ;
答案 1 :(得分:0)
您是否指出要使用哪个数据库?我通常做
USE databasename;
CREATE TABLE tablename (
name_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
(etc....)
);
等。