BeenZ
BeenZ
2008-08-18 08:42
浏览 277
已采纳

请问mysql如何导入该数据

小弟刚学mysql,就遇到了大麻烦,网上的帖子也给得不够详细,一直无法导入数据,急啊
困难如下:现有一文件,名字:dir.des.scop.txt ,小弟不知道如何导入进mysql中.希望高手说明的时候能详细一点,包括建什么库,如何建,还有建什么表,如何建,小弟跪谢

数据部分内容

dir.des.scop.txt

SCOP release 1.69 (July 2005) [File format version 1.00]

http://scop.mrc-lmb.cam.ac.uk/scop/

Copyright (c) 1994-2005 the scop authors; see http://scop.mrc-lmb.cam.ac.uk/scop/lic/copy.html

46456 cl a - All alpha proteins
46457 cf a.1 - Globin-like
46458 sf a.1.1 - Globin-like
46459 fa a.1.1.1 - Truncated hemoglobin
46460 dm a.1.1.1 - Protozoan/bacterial hemoglobin
46461 sp a.1.1.1 - Ciliate (Paramecium caudatum)
14982 px a.1.1.1 d1dlwa_ 1dlw A:
100068 px a.1.1.1 d1uvya_ 1uvy A:
46462 sp a.1.1.1 - Green alga (Chlamydomonas eugametos)
14983 px a.1.1.1 d1dlya_ 1dly A:
100067 px a.1.1.1 d1uvxa_ 1uvx A:
81667 sp a.1.1.1 - Cyanobacteria (Synechocystis sp.), pcc 6803
105305 px a.1.1.1 d1s69a_ 1s69 A:
105306 px a.1.1.1 d1s6aa_ 1s6a A:
97827 px a.1.1.1 d1rtxa_ 1rtx A:
79572 px a.1.1.1 d1mwba_ 1mwb A:
63437 sp a.1.1.1 - Mycobacterium tuberculosis, HbN
105096 px a.1.1.1 d1rtea_ 1rte A:
105097 px a.1.1.1 d1rteb_ 1rte B:
62301 px a.1.1.1 d1idra_ 1idr A:
62302 px a.1.1.1 d1idrb_ 1idr B:
105283 px a.1.1.1 d1s61a_ 1s61 A:
105284 px a.1.1.1 d1s61b_ 1s61 B:
105260 px a.1.1.1 d1s56a_ 1s56 A:
105261 px a.1.1.1 d1s56b_ 1s56 B:
88965 sp a.1.1.1 - Mycobacterium tuberculosis, HbO
85673 px a.1.1.1 d1ngka_ 1ngk A:
85674 px a.1.1.1 d1ngkb_ 1ngk B:
85675 px a.1.1.1 d1ngkc_ 1ngk C:
85676 px a.1.1.1 d1ngkd_ 1ngk D:
85677 px a.1.1.1 d1ngke_ 1ngk E:
85678 px a.1.1.1 d1ngkf_ 1ngk F:
85679 px a.1.1.1 d1ngkg_ 1ngk G:
85680 px a.1.1.1 d1ngkh_ 1ngk H:
85681 px a.1.1.1 d1ngki_ 1ngk I:
85682 px a.1.1.1 d1ngkj_ 1ngk J:
85683 px a.1.1.1 d1ngkk_ 1ngk K:
85684 px a.1.1.1 d1ngkl_ 1ngk L:
74660 fa a.1.1.4 - Nerve tissue mini-hemoglobin (neural globin)
74661 dm a.1.1.4 - Nerve tissue mini-hemoglobin (neural globin)
74662 sp a.1.1.4 - Milky ribbon-worm (Cerebratulus lacteus)
72890 px a.1.1.4 d1kr7a_ 1kr7 A:
108201 px a.1.1.4 d1v07a_ 1v07 A:
46463 fa a.1.1.2 - Globins
46464 dm a.1.1.2 - Hemoglobin I
46465 sp a.1.1.2 - Ark clam (Scapharca inaequivalvis)
14984 px a.1.1.2 d3sdha_ 3sdh A:
14985 px a.1.1.2 d3sdhb_ 3sdh B:
14986 px a.1.1.2 d3hbia_ 3hbi A:
14987 px a.1.1.2 d3hbib_ 3hbi B:
67865 px a.1.1.2 d1jzla_ 1jzl A:
67866 px a.1.1.2 d1jzlb_ 1jzl B:
14988 px a.1.1.2 d4sdha_ 4sdh A:
14989 px a.1.1.2 d4sdhb_ 4sdh B:
14992 px a.1.1.2 d5hbia_ 5hbi A:
14993 px a.1.1.2 d5hbib_ 5hbi B:
14994 px a.1.1.2 d7hbia_ 7hbi A:
14995 px a.1.1.2 d7hbib_ 7hbi B:
14990 px a.1.1.2 d4hbia_ 4hbi A:
14991 px a.1.1.2 d4hbib_ 4hbi B:
14996 px a.1.1.2 d1hbia_ 1hbi A:
14997 px a.1.1.2 d1hbib_ 1hbi B:
14998 px
[b]问题补充:[/b]
mysql> use dir
Database changed
mysql> create table tt(id bigint,name varchar(20));
Query OK, 0 rows affected (0.13 sec)

mysql> insert into tt value(1,'1');
Query OK, 1 row affected (0.05 sec)

mysql> select * form tt;
ERROR 1064 (42000): 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 'form
tt' at line 1
mysql> select * from tt;
+------+------+
| id | name |
+------+------+
| 1 | 1 |
+------+------+
1 row in set (0.03 sec)

mysql> load data infile 'dir.hie.scop.txt' into table tt;
ERROR 1366 (HY000): Incorrect integer value: '# dir.hie.scop.txt ' for column 'i
d' at row 1

lggege 麻烦您看下这个是什么情况

[b]问题补充:[/b]
是否建表的时候要和导入的数据类型,数据数量对应呢?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • lggegegmail
    lggegegmail 2008-08-18 10:05
    已采纳

    [code="java"]C:\Documents and Settings\lg>mysql -u root
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 12 to server version: 5.0.27-community

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql> create database test;
    Query OK, 1 row affected (0.02 sec)

    mysql> use test;
    Database changed

    mysql> create table tt(id bigint, name varchar(20));
    Query OK, 0 rows affected (0.01 sec)

    mysql> insert into tt values(1, '1');
    Query OK, 1 row affected (0.00 sec)

    mysql> select * from tt;
    +------+------+
    | id | name |
    +------+------+
    | 1 | 1 |
    +------+------+
    1 row in set (0.01 sec)

    mysql> select * into outfile 'tt.txt' from tt;
    Query OK, 1 row affected (0.00 sec)

    mysql> delete from tt;
    Query OK, 1 row affected (0.00 sec)

    mysql> select * from tt;
    Empty set (0.00 sec)

    mysql> load data infile 'tt.txt' into table tt;
    Query OK, 1 row affected (0.00 sec)
    Records: 1 Deleted: 0 Skipped: 0 Warnings: 0

    mysql> select * from tt;
    +------+------+
    | id | name |
    +------+------+
    | 1 | 1 |
    +------+------+
    1 row in set (0.00 sec)[/code]

    点赞 评论
  • iteye_1124
    iteye_1124 2008-08-18 09:54

    楼主,不要这样导,mysql不是这样导数据的,你有sql文件吗
    直接在mysql命令行source 你的sql文件的路径就好了

    点赞 评论
  • lggegegmail
    lggegegmail 2008-08-18 10:10

    创数据库
    [code="sql"]mysql> create database test; [/code]

    连接到这个数据库
    [code="sql"]mysql> use test; [/code]

    创表
    [code="sql"]mysql> create table tt(id bigint, name varchar(20)); [/code]

    插入数据
    [code="sql"]mysql> insert into tt values(1, '1'); [/code]

    导数据到某个文件里面,这个tt.txt会在你的 mysql目录\data\test 下(test是数据库名).
    [code="sql"]mysql> select * into outfile 'tt.txt' from tt; [/code]

    从某个文件将数据导回到数据库的某个表.
    [code="sql"]mysql> load data infile 'tt.txt' into table tt; [/code]

    需要去了解下面这个语法, 因为中间还有什么REPLACE覆盖相同数据,IGNORE忽略相同数据的用法.
    [b]LOAD DATA INFILE [/b]

    点赞 评论
  • sunnywolf1010
    sunnywolf1010 2008-08-18 12:53

    有sql文件的话在命令行下直接执行sql文件。 命令: . ***.sql

    点赞 评论

相关推荐