List:General Discussion« Previous MessageNext Message »
From:Jerry Schwartz Date:March 17 2010 3:49pm
Subject:RE: Trancate table from command line?
View as plain text  
>-----Original Message-----
>From: Jerry Schwartz [mailto:jschwartz@stripped]
>Sent: Wednesday, March 17, 2010 10:07 AM
>To: '??????? ????????'; 'John Oliver'
>Cc: mysql@stripped
>Subject: RE: Trancate table from command line?
>
>Am I missing something? Doesn't the -e parameter for the mysql CLI still 
>work?
>I use it all the time in my scripts.
>
>mysql -ulogin -ppassword -e "truncate sometable" your_dbname
>
[JS] Obviously, I meant "truncate table sometable".

>Regards,
>
>Jerry Schwartz
>The Infoshop by Global Information Incorporated
>195 Farmington Ave.
>Farmington, CT 06032
>
>860.674.8796 / FAX: 860.674.8341
>
>www.the-infoshop.com
>
>>-----Original Message-----
>>From: ??????? ???????? [mailto:ekilimchuk@stripped]
>>Sent: Wednesday, March 17, 2010 1:57 AM
>>To: John Oliver
>>Cc: mysql@stripped
>>Subject: Re: Trancate table from command line?
>>
>>If you use *nix, you can use this form:
>>
>>*echo* "TRUNCATE TABLE you_table_name;" | *mysql* -A your_db_name -ulogin
>>-ppassword
>>
>>And:
>>
>>*cat* your_file.sql | *mysql* -A your_db_name -ulogin -ppassword
>>
>>
>>2010/3/17 John Oliver <joliver@stripped>
>>
>>> Is there a way to use mysqladmin (or mysql) to truncate a table as a
>>> one-off command from the command line?
>>>
>>> I have an issue with importing data from one database into another, but
>>> the second database might have columns that the first did not.
>>>
>>> On database 1, I use mysqldump to grab certain tables, and when I try to
>>> simply "overlay" those tables onto the new database, I get an error
>>>
>>> ERROR 1062 (23000) at line 24: Duplicate entry '378-4' for key 1
>>>
>>> So we're thinking we should truncate the table first, but it appears
>>> this must be done manually in the mysql> shell, which won't work... this
>>> operation needs to be scripted, or to be presented as one command line
>>> that can be copy-and-pasted.
>>>
>>> How can I do something like :
>>>
>>> mysqladmin -h db_server -u user -pPASSWORD <DATABASE> truncate table
>>> table1 ?
>>>
>>> --
>>> ***********************************************************************
>>> * John Oliver                             http://www.john-oliver.net/ *
>>> *                                                                     *
>>> ***********************************************************************
>>>
>>> --
>>> MySQL General Mailing List
>>> For list archives: http://lists.mysql.com/mysql
>>> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>>>
>>>
>>
>>
>>--
>>Best regards,
>>
>>Eugene Kilimchuk <ekilimchuk@stripped>
>
>
>
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>infoshop.com




Thread
Trancate table from command line?John Oliver16 Mar
  • Re: Trancate table from command line?John Oliver17 Mar
  • Re: Trancate table from command line?Евгений Килимчук17 Mar
    • RE: Trancate table from command line?Jerry Schwartz17 Mar
      • RE: Trancate table from command line?Jerry Schwartz17 Mar
  • RE: Trancate table from command line?Carlos Eduardo Caldi17 Mar