How we can copy one table data into another table whose name
same as table but in differ database
Answers were Sorted based on User's Feedback
Answer / jayanthi reddy
create table tablename select * from databasename.tablename
i'm expecting this will work. if anything wrong correct it
| Is This Answer Correct ? | 8 Yes | 7 No |
Answer / jyoti
SELECT *
INTO table_name [IN externaldatabase]
FROM tablename
| Is This Answer Correct ? | 4 Yes | 3 No |
Answer / payal
select * into databasename.<TableName> from (select * from
databasename.<TableName>)
| Is This Answer Correct ? | 10 Yes | 10 No |
Answer / nikki
i think it is not possible to execute query at a time for
two database
| Is This Answer Correct ? | 4 Yes | 4 No |
Answer / saket bharti
create table database2.tablename as (select * from
database1.tablename where 1=2);
This will create a new table in database2 with the same
structure as the table in database1 ,but will not contain
any values or constraints of database1 table.
create table database2.tablename as (select * from
database1.tablename );
This will create a new table in database2 with all the
structure and values from the table from database1.
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / guru
INSERT INTO database2.table_name (column_name)
SELECT table_name.column_name FROM table_name
If two databases are in same server, this code will work.
For more details visit,
http://www.phponwebsites.com/2013/12/Copy-values-from-one-database-to-another-in-mysql.html
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / bhas
CREATE TABLE `bhas`.`cds` ( table structure and data)
INSERT INTO `bhas`.`cds`
SELECT *
FROM `cdcol`.`cds` ;
where bhas is new db and cds is table name, cdcol is old db
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / mahesh murali
select * into db1.db1_table from (select * from
db2.db2_table)
| Is This Answer Correct ? | 0 Yes | 4 No |
How to allow the user "sonia" to connect to the server from localhost using the password "passwd". Login as root. Switch to the mysql db. Give privs. Update privs.
How to start mysql server?
What are the functions used to encrypt and decrypt the data present in mysql?
How do I create a database in mysql workbench?
how to Return total number of rows.
How to get the number of rows selected or affected by a sql statement?
Which is better sqlite or mysql?
How to Set a root password if there is on root password.
What is information_schema in mysql?
How to run 'mysql' commands from a batch file?
How do you rename a procedure in mysql?
how many ways we can get the current date in mysql?
Oracle (3253)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)