LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 03-18-2015, 04:34 AM   #1
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Rep: Reputation: Disabled
how to bulk update mysql data


I have a database , there are some table in it , in this database , there is a string "error" , I would like to change it to "warning" , except export all data to text , find and replace string , and then import back to database , is there other method may bulk update the string ? thanks
 
Old 03-18-2015, 05:13 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
Code:
UPDATE tablename SET thefield = REPLACE(thefield, 'error', 'warning');
From the first hit on google for "update replace MySQL" https://www.google.com/search?q=update+replace+mysql Google is an amazing resource, should try it sometime.
 
Old 03-18-2015, 05:30 AM   #3
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
Code:
UPDATE tablename SET thefield = REPLACE(thefield, 'error', 'warning');
From the first hit on google for "update replace MySQL" https://www.google.com/search?q=update+replace+mysql Google is an amazing resource, should try it sometime.
thanks reply,

sorry to my fool , what is the mean of "thefield" , I just copy your whole command will be fine ?

thanks
 
Old 03-18-2015, 05:47 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
Quote:
Originally Posted by byran cheung View Post
sorry to my fool , what is the mean of "thefield" ,
Replace it with the name of the field you want to change the value in. If you have more than one table or more than one field you'll have to do each table individually.
Quote:
Originally Posted by byran cheung View Post
I just copy your whole command will be fine ?
No, see above, you'll have to change the table and field name appropriately.
 
Old 03-18-2015, 12:23 PM   #5
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
Replace it with the name of the field you want to change the value in. If you have more than one table or more than one field you'll have to do each table individually.
No, see above, you'll have to change the table and field name appropriately.
thanks reply ,
"you'll have to change the table and field name appropriately." <<= is there any command that can change data in all table / field by one time , as I have so many tables .

Thanks
 
Old 03-18-2015, 12:30 PM   #6
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
Quote:
Originally Posted by byran cheung View Post
is there any command that can change data in all table / field by one time
Not as standard. Also beware of doing a global search/replace in a mysqldump file as you may also change table/column names.
 
  


Reply


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
Hibernate not inserting Bulk data in MySQL AkhilSJSU Linux - Enterprise 1 10-29-2014 03:41 PM
Bulk abd real data transfer over ad hoc/WLAN network under Fedora 13 Gabrial Linux - Networking 0 08-21-2010 10:19 AM
help with mysql command to update data in a table ncsuapex Programming 2 09-30-2008 12:32 PM
Is there any alternative for cp aommand in linux to copy bulk data ????? madhuri_aage Linux - Software 2 02-13-2006 10:14 AM
MySQL bulk URL update - regular expressions? lowpro2k3 Programming 1 06-13-2005 04:42 PM


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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration