LinuxQuestions.org
Help answer threads with 0 replies.
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 03-18-2015, 03: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, 04:13 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
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, 04: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, 04:47 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
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, 11:23 AM   #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, 11:30 AM   #6
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
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



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

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

All times are GMT -5. The time now is 03:32 PM.

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