LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-03-2014, 06:39 PM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 672

Rep: Reputation: 46
Question Single Command ninjitsu | mysql truncate tables after import


Hey LQ,

I'm making some scripts that will eventually rsync a whole website to a development server. I've managed to get it to remotely create an sql backup, copy it to the dev server and perform a mysql import. Now what I want to do is truncate two tables which contain transaction data.

So something like

Code:
mysql -u root -pPassword customer_sales | truncate customer_credit_info | truncate customer_information;
How would I go about doing this?

Last edited by wh33t; 09-03-2014 at 06:54 PM.
 
Old 09-03-2014, 07:39 PM   #2
solarisguy
Member
 
Registered: Aug 2010
Location: Seattle
Distribution: CentOS, RHEL, Oracle Enterprise Linux, Solaris, BSD
Posts: 64

Rep: Reputation: 18
You're on the right track with pipelining, it's just in the incorrect order.

Here's what you're wanting:
Code:
echo "truncate customer_credit_info; truncate customer_information;" | mysql -u root -pPassword customer_sales
 
1 members found this post helpful.
Old 09-03-2014, 11:09 PM   #3
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 672

Original Poster
Rep: Reputation: 46
Cool

Quote:
Originally Posted by solarisguy View Post
You're on the right track with pipelining, it's just in the incorrect order.

Here's what you're wanting:
Code:
echo "truncate customer_credit_info; truncate customer_information;" | mysql -u root -pPassword customer_sales
Thanks! I really appreciate it.
 
  


Reply

Tags
mysql single command


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to backup all mysql database individually in single command sanjay87 Linux - Server 6 03-17-2012 02:19 PM
[SOLVED] MySQL grant tables - how can I import them from another DB? Skaperen Linux - Software 8 09-29-2011 11:01 AM
lowercase windows mysql tables became uppercase import to linux Niceman2005 Linux - Software 2 06-06-2006 03:18 AM
Import sys ?bash: import: command not found joirnange Linux - Newbie 4 12-28-2004 11:33 PM
MySQL - command - create user/single database dmedici Linux - Software 3 06-21-2004 04:17 PM


All times are GMT -5. The time now is 11:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration