Sapna Malik
How to transfer a table from one schema to another?
By Sapna Malik in Databases & DBA on Mar 16 2011
  • Ankita Kumari
    Mar, 2023 23

    To transfer a table from one schema to another in MySQL, you can use the CREATE TABLE statement with the AS keyword to create a new table in the target schema based on the structure and data of the original table. Here are the steps:

    Open a MySQL client and connect to the MySQL server where the original schema and target schema exist.

    Select the source schema using the USE statement:
    USE original_schema;
    Create a new table in the target schema using the CREATE TABLE statement with the AS keyword:
    CREATE TABLE target_schema.new_table AS SELECT * FROM original_table;
    This statement creates a new table called new_table in the target_schema with the same structure and data as the original_table.

    (Optional) If you want to remove the original table from the source schema, you can use the DROP TABLE statement:
    DROP TABLE original_table;
    This statement deletes the original_table from the original_schema.

    That’s it! You have now transferred a table from one schema to another

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS