Copying MySQL table data to another table - mysql

I want to copy the data from one MySQL table to another table. The source table contains 30 million records. the SQL connection gets lost when I tried to copy the data using the SQL query
INSERT table2 SELECT * FROM table1
Is there any external tool avaliable to do this job from the shell
Thanks
Sree

The mysql command line tool should be able to handle this just fine.

Related

How can I copy a table from one database to another database along with its data?

I have two separate databases installed on the same server. I name the representation as db1 and db2. I have a table named sample_table in my db1 database. I am trying to copy this table with its records to my db2 database with the following queries:
CREATE TABLE db2.sample_table LIKE db1.sample_table
insert into db2.sample_table select * from db1.sample_table
As a result of my research, I found that this method works in most places. However, when I type and run my query from the db2 console, I am having a user permission problem for db1. The query might be running, but should there be a configuration link between these two databases? If so, how can I get this link? What are the alternative solution methods I can overcome this problem?

Zend DB MySQL not insert in certain tables

We have the same code running on different MySQL databases, saying db1, db2...and etc. We insert records into table1 for every db, like db1.table1, db2.table2...etc.
The same piece of code written in Zend DB Adapter can insert every table1 in every database, except one. Compare the database schema and they are all created the same. Manually inserting the record to the table1 is successful in every table.
What could be the possible reasons? How to further troubleshoot?
The MySQL version is 5.0.0.7.

Need insight into script to copy InnoDB tables to another database

I have a mysql database with InnoDB tables that I need to copy into a newly created database. I would like to automate the copying process with a script since there are over 100 tables.
This is my current code. After 10 tables, it's getting tiresome:
> use newdb;
> CREATE TABLE tableA LIKE old_db.tableA
> INSERT INTO tableA SELECT * FROM old_db.tableA
How can I extract the table names from old_db in order to automate this process?
Use MySQLWorkbench to export the schema and data from the source database and then import into the new database.

Update MySQL database Table from another Table in different location

I have the following issue related to I have in localhost(my computer) a Table in a database which I use to update the data for a month. Once data is correct, I need to update the Table in the database which resides in the server.
I use Navicat to do the work and it only transfer data deleting the actual database in the server and sending all the data from my localhost.
The problem is that the Table now has almost 300.000 records stored and it takes too long transfering the data leaving the database empty for some time.
Is there any way I could use that only update the data without deleting the whole table?
export local table with different name as mysqldump or just csv, 300k rows is not a big deal and use a different table now.
then upload the table 2 to db and use a query to update table 1 using table2 data.

Query two databases in Monetdb

Im using monetdb and i have two databases on it "mydb" and "test".
I want to get a sub-set of values from 'mydb' into 'test'.
My code:
insert into test.result
select sum(chargfeeprepaid) from mydb.data where callingpartyno = 628388881507
union
select sum(chargefeeprepaid) from mydb.sms where callingpartyno = 628388881507;
This works fine in MySQL...but in Monetdb i get the error: INSERT INTO: no such scheme 'test'.
Where did i go wrong and what is the correct syntax to do this in monetdb?
Greetings Seleen
There is no way to do this in MonetDB. Every Database is served by it's own process (mserver) and there is no sharing between them.
If you want to migrate data from one database to another you have to either copy the data using the copy commands (see http://goo.gl/OXkto) or dump the data as sql inserts using the dump commands ( http://goo.gl/5Bfrf and http://goo.gl/EuPwE).