MySQL创建表时写错命令,从命令行Mysql创建表时出现问题

When I type in the code into the Terminal it creates the Database but doesn't create the Table.

When I type in use "locations" then "Show TABLES" it tells me that no Tables were created.

This code should create a Database and the Table then import the the csv file into the database "locations"

解决方案

Here is a full answer, based off of @Honeyboy's comment.

In addition to needing to USE locations; there are some other things to fix:

Shell quoting wasn't really quite right. For one thing, your existing code doesn't account for the line breaks -- it needs line continuation escapes to run as written.

The name of the table changed between the CREATE TABLE statement and the LOAD DATA statement

The LOAD DATA statement didn't ignore the header row of your tab delimited file.

mysql -u root --password=password -e \

'CREATE DATABASE locations; \

USE locations; \

CREATE TABLE location_T (number1 INT NOT NULL, \

number2 INT NOT NULL, \

number3 INT NOT NULL, \

names VARCHAR(100) NOT NULL,PRIMARY KEY (number1)); \

LOAD DATA LOCAL INFILE "locations.csv" \

INTO TABLE location_T FIELDS TERMINATED by "\t" \

ENCLOSED BY "\"" LINES TERMINATED BY "\n" IGNORE 1 LINES \

(number1,number2,number3,names)'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值