Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

move table from one schema to another schema ?

Tags:

database

mysql

I want to move table from one schema to another schema in mysql , can anybody tell me how can I do this .

like image 259
p27 Avatar asked May 06 '11 10:05

p27


People also ask

How do I transfer a table from one schema to another schema?

To change the schema of a table by using SQL Server Management Studio, in Object Explorer, right-click on the table and then click Design. Press F4 to open the Properties window. In the Schema box, select a new schema.

How do I copy a table from one schema to another schema in Oracle?

right click on table >> Table>>COPY>> select the schema where you want to copy.

How do I copy a table from one schema to another schema in MySQL?

Copy a table from one database to another. In MySQL, the easiest way to copy a table with its data between two databases is to use the CREATE TABLE AS statement, but note, that you need to provide the target database name as a table prefix. CREATE TABLE new-database-name. new-table-name AS SELECT * FROM old-database.


2 Answers

If both schema is on same server then Alter table can be used to move tables from one db to another.

alter table old_db.fooTable rename new_db.fooTable
like image 55
Harry Joy Avatar answered Nov 12 '22 12:11

Harry Joy


Moving tables with space characters in between should be enclosed.

Example:

ALTER TABLE `schema1`.`tbl somename` 
RENAME TO  `schema2`.`tbl somename` ;
like image 4
Kruti Mehta Avatar answered Nov 12 '22 12:11

Kruti Mehta