List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:March 22 2003 4:28am
Subject:Re: Importing into an AutoIncrement field
View as plain text  
At 20:04 -0800 3/21/03, Todd Cary wrote:
><div class="moz-text-flowed" style="font-family: -moz-fixed">I would 
>like to avoid the necessity of specifying all of the fields -
>instead use the following syntax:
>
>INSERT INTO teachers VALUES
>(1,12345,NULL,'Harry','Smith','707-773-4523',2',...
>
>However, the first field is an autoincrementing field.  Will MySQL
>ignore my value and overwrite it with the "auto" value?

No.  It will only generate an auto-increment value if you specify NULL or
omit the column value from the statement.  In the latter case you
must provide a column list so that MySQL knows which data values go in
which clients.

If you specify an explicit value for the auto-increment column (as you
do above), and the value already exists in the table, you'll get a
duplicate key error, assuming that you've declared it as a PRIMARY KEY
or UNIQUE index.

>
>The next is question is the command line syntax for importing a file
>liek the above?  I have never done it and I am using the Linux version
>of MySQL.

I don't understand the question.  It appears to defy parsing. :-)

>
>Todd
>
>--
>Ariste Software, Petaluma, CA 94952 \n info@stripped
>
></div>


-- 
Paul DuBois
http://www.kitebird.com/
sql, query
Thread
Importing into an AutoIncrement fieldTodd Cary22 Mar
  • Re: Importing into an AutoIncrement fieldPaul DuBois22 Mar
    • Re: Importing into an AutoIncrement fieldPaul DuBois22 Mar