LOAD DATA INFILE and AUTO_INCREMENT

    Date: 07/25/06 (MySQL Communtiy)    Keywords: mysql, database, sql

    hi all

    I'm trying to import data into a table with a column that has AUTO_INCREMENT:

    MYSQL> desc stats;
    +-------+---------------------+------+-----+---------+----------------+
    | Field | Type                | Null | Key | Default | Extra          |
    +-------+---------------------+------+-----+---------+----------------+
    | id    | bigint(20) unsigned |      | PRI | NULL    | auto_increment |
    | date  | bigint(14) unsigned | YES  |     | NULL    |                |
    | ent1  | varchar(10)         |      |     |         |                |
    | ent2  | varchar(10)         |      |     |         |                |
    +-------+---------------------+------+-----+---------+----------------+
    
    LOAD DATA INFILE "stats.txt" INTO TABLE stats (date, ent1, ent2);
    Query OK, 140 rows affected (0.01 sec)
    Records: 140  Deleted: 0  Skipped: 0  Warnings: 0
    

    There are 140 lines in stats.txt, fields are terminated by a tab, lines are terminated by a new line. I get 140 new entries, but "id" column (auto_increment) is "0":
    +------+----------------+------------+------------+
    | id   | date           | prid       | did        |
    +------+----------------+------------+------------+
              
    | 3870 | 20060725133314 | FFFFFFFFFF | f111111111 |
    | 3871 | 20060725133613 | FCCCCCCCCC | f222222222 |
    | 3872 | 20060725133722 | FDDDDDDDDD | d333333333 |
    |  0   | 20060704011139 | FVVVVVVVVV | e111111111 |
    |  0   | 20060704104952 | LSSSSSSSSS | f222222222 |
              
    |  0   | 20060720161936 | FDDDDDDDDD | d111111111 |
    +------+----------------+------------+------------+
    


    So, that is the problem. I just wonder this is a very common question, but I am new in databases...
    Any of your help will be appreciated.

    Best,
    Leo

    Source: http://community.livejournal.com/mysql/100368.html

« php/mySQL question || Organisations that change »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home