Is there a way to copy the column structure from an already filled table to a new table that is empty? I only ask for a copy structure without data
Example: We have a table
CREATE TABLE `animals` ( `animal` varchar(11) NOT NULL, `food` varchar(11) NOT NULL, PRIMARY KEY (`animal`) ) ENGINE=InnoDB INSERT INTO `animals` (`animal`, `food`) VALUES ('cat', 'chips'), ('dog', 'bones'), ('shark', 'ppl');
And a new table called predators , for which I want to make only one column, but with the same data type as the column type for animals.
Is there a way to combine SHOW COLUMNS / SQUARE with CREATE TABLE or create a table with a column that has some type like VARCHAR (17) and then ALTER change it to the same type as the animal column?
I know this is a simple question, but I was not lucky to find an answer to it
source share