我对CSV数据文件和MySQL有疑问。我得到一个包含40个表的MySQL数据库,我想从CSV文件中填写llx_societe表中的字段。
我的表格如下:
mysql> select * from llx_societe limit 1 ;
+-------+-----------+------------+--------+---------+---------+--------+--------+---------------------+-------+--------+-------------+------------------+-------------+-------------------------+----------------------+-------+-------------+----------------+---------+-------+------+------+-------+-------+-------------+-----------+--------------------+-------------+-------+-------+------+---------+---------+---------+-----------+---------+-----------+--------------+-------------+-----------+-------------+--------+-------------+------------------+------------------+--------------+--------------------+--------------+---------------+---------------+---------------+---------------+---------------+----------------+----------------+-------------------------+-------------------------+--------------------+-----------+-----------------+-----------------+-----------------+-----------------+---------+-----------------+-------------+-------------------+--------------+------+--------+------------+-----------------+-----------------+------------------+--------------------+
| rowid | nom | name_alias | entity | ref_ext | ref_int | statut | parent | tms | datec | status | code_client | code_fournisseur | code_compta | code_compta_fournisseur | address | zip | town | fk_departement | fk_pays | phone | fax | url | email | skype | fk_effectif | fk_typent | fk_forme_juridique | fk_currency | siren | siret | ape | idprof4 | idprof5 | idprof6 | tva_intra | capital | fk_stcomm | note_private | note_public | model_pdf | prefix_comm | client | fournisseur | supplier_account | fk_prospectlevel | fk_incoterms | location_incoterms | customer_bad | customer_rate | supplier_rate | fk_user_creat | fk_user_modif | remise_client | mode_reglement | cond_reglement | mode_reglement_supplier | cond_reglement_supplier | fk_shipping_method | tva_assuj | localtax1_assuj | localtax1_value | localtax2_assuj | localtax2_value | barcode | fk_barcode_type | price_level | outstanding_limit | default_lang | logo | canvas | import_key | webservices_url | webservices_key | fk_multicurrency | multicurrency_code |
+-------+-----------+------------+--------+---------+---------+--------+--------+---------------------+-------+--------+-------------+------------------+-------------+-------------------------+----------------------+-------+-------------+----------------+---------+-------+------+------+-------+-------+-------------+-----------+--------------------+-------------+-------+-------+------+---------+---------+---------+-----------+---------+-----------+--------------+-------------+-----------+-------------+--------+-------------+------------------+------------------+--------------+--------------------+--------------+---------------+---------------+---------------+---------------+---------------+----------------+----------------+-------------------------+-------------------------+--------------------+-----------+-----------------+-----------------+-----------------+-----------------+---------+-----------------+-------------+-------------------+--------------+------+--------+------------+-----------------+-----------------+------------------+--------------------+
| 1 | A.D.P.N. | NULL | 1 | NULL | NULL | 0 | NULL | 2016-06-02 10:11:46 | NULL | 1 | NULL | NULL | NULL | NULL | 5 rue des Narcisses | 67116 | REICHSTETT | 0 | 1 | | NULL | NULL | NULL | NULL | 0 | 8 | 38 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 | NULL | NULL | NULL | NULL | 1 | 0 | NULL | NULL | NULL | NULL | 0 | 0 | 0 | NULL | NULL | 0 | NULL | NULL | NULL | NULL | NULL | 0 | 0 | NULL | 0 | NULL | NULL | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
+-------+-----------+------------+--------+---------+---------+--------+--------+---------------------+-------+--------+-------------+------------------+-------------+-------------------------+----------------------+-------+-------------+----------------+---------+-------+------+------+-------+-------+-------------+-----------+--------------------+-------------+-------+-------+------+---------+---------+---------+-----------+---------+-----------+--------------+-------------+-----------+-------------+--------+-------------+------------------+------------------+--------------+--------------------+--------------+---------------+---------------+---------------+---------------+---------------+----------------+----------------+-------------------------+-------------------------+--------------------+-----------+-----------------+-----------------+-----------------+-----------------+---------+-----------------+-------------+-------------------+--------------+------+--------+------------+-----------------+-----------------+------------------+--------------------+
1 row in set (0.00 sec)
我想用一个看似如下的CSV文件填充code_client字段:
1
20
30
40
60
70
90
17
因此,我的llx_societe表中的每一行都对应一个CSV文件号。
rowid 1 : code_client = 1
rowid 2 : code_client = 20
rowid 3 : code_client = 30
...
我在纸上提醒我如何做到这一点,而且我不知道在哪里需要指定该字段:
mysql> use dolibarr ;
mysql> LOAD DATA INFILE '~/code_client.csv'
REPLACE INTO TABLE 'llx_societe'
CHARACTER SET 'utf8'
FIELDS TERMINATED BY '|'
LINES TERMINATED BY '\r\n'
但是我必须指定code_client MySQL列吗?
感谢您帮助我,对不起,如果我的英语不完美^^