Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create MySQL query to create a table from an existing table

Tags:

People also ask

How do I create a table from another table in MySQL?

You can create one table from another by adding a SELECT statement at the end of the CREATE TABLE statement: CREATE TABLE new_tbl [AS] SELECT * FROM orig_tbl; MySQL creates new columns for all elements in the SELECT .

What is the query to create a table from existing table?

Question: How can I create a SQL table from another table without copying any values from the old table? Answer: To do this, the SQL CREATE TABLE syntax is: CREATE TABLE new_table AS (SELECT * FROM old_table WHERE 1=2);

How do I create a table query in MySQL?

In MySQL workbench, you get the already created table script, by just right click on the specific table, then select send to SQL editor>>create statement . That's all you will get the create table script on the editor.


I have quite a large and complex table in a MySQL database that would be a pain to have to build a query for manually to recreate if anything went wrong.

Is there someway I can get MySQL or some other tool/script I can use to get a Query made automatically that would recreate the structure of the table?

Ideally if you suggested a tool/script it would be for Linux