Sponsored Content
Top Forums Programming MySQL auto_increment, primary key Post 302590527 by yifangt on Monday 16th of January 2012 02:47:43 PM
Old 01-16-2012
format of the input file and shifted columns in the result.

Thanks!
Here is the head of the input file in tab-delimited format. Please notice that the second column may be empty in some rows and maybe be more than two items separated by comma.
Code:
AGI_Number      Symbols Computational_description                            Chromosome     Orientation Start       End            AA_Length
AT1G75120.1     RRA1    Nucleotide-diphospho-sugar transferase family protein   chr1    REVERSE 28197022        28198656        402
AT1G17600.1             Disease resistance protein (TIR-NBS-LRR class) family   chr1    REVERSE 6053026         6056572            1049
AT1G51380.1             DEA(D/H)-box RNA helicase family protein                chr1    FORWARD 19047960        19049967        392
AT1G77370.1             Glutaredoxin family protein                         chr1    FORWARD 29073916        29074642        130
AT1G44090.1     ATGA20OX5, GA20OX5      gibberellin 20-oxidase 5                chr1    REVERSE 16760677        16762486        385

And I created the table by:
Code:
DROP TABLE IF EXISTS test_agi;

CREATE TABLE if NOT EXISTS test_agi (
    Run_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
     AGI_Number text(30),
     Symbols text(100),
     Computational_description text(1000),
     Chromosome VARCHAR(10),
     Orientation VARCHAR(20),     
     Start INT,
     End INT,
     AA_Length INT NOT NULL
     ) ;

LOAD DATA 
     LOCAL INFILE "/home/yifang/20111210-Project-At-Br-Bd-Os-Gm/Blast-Result/At-as-subject/e10/TAIR10_representative_gene_model-cleaned.csv" 
 INTO
     TABLE test_agi 
     FIELDS TERMINATED BY '\t' 
     LINES TERMINATED BY '\n';

Then I check the table:
Code:
mysql> select Run_ID, AGI_Number, Start, End, Orientation, Chromosome from test_agi limit 10;
+--------+--------------------+----------+------+-------------+------------+
| Run_ID | AGI_Number         | Start    | End  | Orientation | Chromosome |
+--------+--------------------+----------+------+-------------+------------+
|      1 |                    | 18872570 |  671 | 18870555    | FORWARD    |
|      2 |                    | 14015508 |  181 | 14014796    | FORWARD    |
|      3 |                    | 16718656 |  577 | 16716692    | REVERSE    |
|      4 |                    |  5488494 |  352 | 5486544     | REVERSE    |
|      5 |                    | 27612182 |  254 | 27611418    | FORWARD    |
|      6 | RRA1               | 28198656 |  402 | 28197022    | REVERSE    |
|      7 |                    |  6056572 | 1049 | 6053026     | REVERSE    |
|      8 |                    | 19049967 |  392 | 19047960    | FORWARD    |
|      9 |                    | 29074642 |  130 | 29073916    | FORWARD    |
|     10 | ATGA20OX5, GA20OX5 | 16762486 |  385 | 16760677    | REVERSE    |
+--------+--------------------+----------+------+-------------+------------+
10 rows in set (0.00 sec)

It can be seen that the columns are shifted and, the AGI_Number, AA_Length are not correctly input (Not showing as my screen is small!). I was thinking the Run_ID is the problem as it is not in the raw data file.

Yes, the primary key can be added by altering the table later, but can it be set here too? Not very experienced with MySQL and lots to learn. Thank you for your education!
 

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Pressing backspace key simulates enter key

Hi, Whenever i press the backspace key, a new line appears, i.e. it works like a enter key. :confused: Thanks (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies

2. Web Development

MySQL Replication Issues: Duplicate Key Error

Lately my attention has been focused on distributed MySQL database replication to other web servers. All was going well, but then I noticed the replication would stop and there were there "Duplicate Primary Key" errors in SHOW SLAVE STATUS; I started to trace these down and noticed that this... (2 Replies)
Discussion started by: Neo
2 Replies

3. Solaris

Solaris 8 ssh public key authentication issue - Server refused our key

Hi, I've used the following way to set ssh public key authentication and it is working fine on Solaris 10, RedHat Linux and SuSE Linux servers without any problem. But I got error 'Server refused our key' on Solaris 8 system. Solaris 8 uses SSH2 too. Why? Please help. Thanks. ... (1 Reply)
Discussion started by: aixlover
1 Replies

4. UNIX and Linux Applications

MySQL Daemon failed to start - no mysql.sock file

After doing a yum install mysql mysql-server on Fedora 14 I wasn't able to fully install the packages correctly. It installed MySQL 5.1. I was getting the following error when running the: mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)... (3 Replies)
Discussion started by: jastanle84
3 Replies

5. Programming

Identifying a missing primary key

I have the following method to identify missing primary keys in a MySQL database schema: USE information_schema; SELECT xx.table_name FROM (SELECT table_name, COUNT(*) FROM columns WHERE table_schema = @myDB GROUP BY table_name, column_key) xx GROUP BY xx.table_name HAVING COUNT(*) = 1; I... (0 Replies)
Discussion started by: figaro
0 Replies

6. Solaris

Primary key issue when running Oracle sql file

I got a issue with running the following script below if I remove the inserts and alter table the tables will install just fine but if I try and do the full thing in one go i get the below error dose any one have any ideas on this problem? its got me spinning, thanks. REM REM List of... (1 Reply)
Discussion started by: Wpgn
1 Replies
All times are GMT -4. The time now is 07:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy