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 .
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);
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With