Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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



How we can copy one table data into another table whose name same as table but in differ database..

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

How we can copy one table data into another table whose name same as table but in differ database..

Answer / jyoti

SELECT *
INTO table_name [IN externaldatabase]
FROM tablename

Is This Answer Correct ?    4 Yes 3 No

How we can copy one table data into another table whose name same as table but in differ database..

Answer / payal

select * into databasename.<TableName> from (select * from
databasename.<TableName>)

Is This Answer Correct ?    10 Yes 10 No

How we can copy one table data into another table whose name same as table but in differ database..

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

How we can copy one table data into another table whose name same as table but in differ database..

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

How we can copy one table data into another table whose name same as table but in differ database..

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

How we can copy one table data into another table whose name same as table but in differ database..

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

How we can copy one table data into another table whose name same as table but in differ database..

Answer / mahesh murali

select * into db1.db1_table from (select * from
db2.db2_table)

Is This Answer Correct ?    0 Yes 4 No

Post New Answer



More MySQL Interview Questions

How can you filter the duplicate data while retrieving records from the table?

0 Answers  


How do I start mysql client?

0 Answers  


How to get nth highest salary from table in a mysql?

0 Answers  


How to use regular expression in pattern match conditions?

0 Answers  


Where is the mysql data directory?

0 Answers  






What is data directory in mysql?

0 Answers  


Where is the myisam table stored?

0 Answers  


Write a query to fetch common records between two tables using mysql?

0 Answers  


How do I install mysql?

0 Answers  


What is inner join in mysql?

0 Answers  


What is mysql workbench used for?

0 Answers  


How do I backup mysql database on linux?

0 Answers  






Categories