LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 05:39 PM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 922

Rep: Reputation: 61
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 05:54 PM.
 
Old 09-03-2014, 06:39 PM   #2
solarisguy
Member
 
Registered: Aug 2010
Location: Seattle
Distribution: CentOS, RHEL, Oracle Enterprise Linux, Solaris, BSD
Posts: 64

Rep: Reputation: 21
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, 10:09 PM   #3
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 922

Original Poster
Rep: Reputation: 61
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



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 01:19 PM
[SOLVED] MySQL grant tables - how can I import them from another DB? Skaperen Linux - Software 8 09-29-2011 10:01 AM
lowercase windows mysql tables became uppercase import to linux Niceman2005 Linux - Software 2 06-06-2006 02:18 AM
Import sys ?bash: import: command not found joirnange Linux - Newbie 4 12-28-2004 10:33 PM
MySQL - command - create user/single database dmedici Linux - Software 3 06-21-2004 03:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:09 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
Open Source Consulting | Domain Registration