List:General Discussion« Previous MessageNext Message »
From:Keith Keller Date:June 15 2012 3:21pm
Subject:Re: console input
View as plain text  
On 2012-06-14, Gary Aitken <mysql@stripped> wrote:
>
> So...  I wanted to read the data line at a time and use a plain INSERT statement. 
> That way I could check for duplicate keys and discover where the duplicate records are. 
> However, I can't find a way to read input from the console or a file.  What am I missing? 
> I know I could write a java or C++ program to do this, but it seems like overkill for what
> should be a trivial task.

Actually, what might make more sense is to use un*x command line tools
to help.  Use cut to extract only the columns of your primary key, use
sort (not with -u!) to sort the rows, and use uniq -d to print out only
duplicate lines.  e.g.

cut -f1 mytable.tab | sort | uniq -d

It won't tell you which line number(s) are problematic, however; it just
tells you which values for your PK are duplicated.  If you need the line
number use one of the other suggestions.

--keith

-- 
kkeller@stripped


Thread
console inputGary Aitken15 Jun
  • Re: console inputKeith Keller15 Jun
    • Re: console inputAnanda Kumar15 Jun
  • Re: console inputJohan De Meersman15 Jun
    • Re: console inputGary Aitken15 Jun
  • Re: console inputShawn Green15 Jun
  • Re: console inputKeith Keller15 Jun