MySQL:错误:无法打开文件error2

时间:2015-07-07 08:55:11

标签: mysql

以下是我的步骤:
1.使用银行(我的数据库);
2.来源d:\ Nitro \ testing \ SQL \ Books_mysql \ Cookbook \ recipes \ tables \ cow.sql

当我尝试为特定的.sql文件(即' cow.sql')提供源代码时,会显示以下错误:

  

ERROR:
  无法打开文件' d:\ Nitro \ testing \ SQL \ Books_mysql \ Cookbook \ recipes \ tables \ cow.sql',错误:2

" cow.sql"的内容:     #在线构建牛排序场景表

DROP TABLE IF EXISTS cow_order;
#@ _CREATE_COW_ORDER_TABLE_
CREATE TABLE cow_order
(
 id          INT UNSIGNED NOT NULL AUTO_INCREMENT,
 # cow color, figurine size, and accessory items
 color VARCHAR(20),
 size ENUM('small','medium','large') DEFAULT 'medium',
 accessories SET('cow bell','horns','nose ring','tail ribbon')
              DEFAULT 'cow bell,horns',
 # customer name, street, city, and state (abbreviation)
 cust_name   VARCHAR(40),
 cust_street VARCHAR(40),
 cust_city   VARCHAR(40),
 cust_state  CHAR(2),
 PRIMARY KEY (id)
 );
 #@ _CREATE_COW_ORDER_TABLE_

 # Add some orders to the table

 INSERT INTO cow_order (color, size, accessories,
                   cust_name, cust_street, cust_city, cust_state)
 VALUES
 ('Black & White','large','cow bell,nose ring',
 'Farmer Brown','123 Elm St.','Bald Knob','AR');

 SELECT * FROM cow_order\G

 DROP TABLE IF EXISTS cow_color;
 #@ _CREATE_COW_COLOR_TABLE_
 CREATE TABLE cow_color (color CHAR(20));
 #@ _CREATE_COW_COLOR_TABLE_

 INSERT INTO cow_color (color)
 VALUES
 ('Black'),
 ('Brown'),
 ('Cream'),
 ('Black & White'),
 ('Red & White'),
 ('Red'),
 ('See-Through');

 SELECT * FROM cow_color;

2 个答案:

答案 0 :(得分:3)

你好像在Windows上。在这里你需要使用正斜杠!

USE bank;

SOURCE D:/Nitro/testing/SQL/Books_mysql/Cookbook/recipes/tables/cow.sql;

或者,您可以使用转义反斜杠:

SOURCE D:\\Nitro\\testing\\SQL\\Books_mysql\\Cookbook\\recipes\\tables\\cow.sql;

答案 1 :(得分:0)

在Windows上,在path中使用正斜杠(/),并提供完整路径。 例如:

select t.*, date(the_debt_paid) - the_debt_due - (extract(dow from the_debt_due) = 0)::int AS date_diff from my_table t