mysql copy column data type to another table -
is there way re-create column's construction populated table new table empty? i'm asking copying construction without data
example: have table
create table `animals` ( `animal` varchar(11) not null, `food` varchar(11) not null, primary key (`animal`) ) engine=innodb insert `animals` (`animal`, `food`) values ('cat', 'chips'), ('dog', 'bones'), ('shark', 'ppl');
and new table called predators
want create 1 column same info type animals' column type.
is there way combine show columns/fields create table or create table column has kind of type varchar(17) , alter alter same type animal
column?
i know simple question haven't had luck finding reply it
if wish re-create data:
insert newtable (col1, col2) select col1, col2 othertable
if wish re-create table structure:
use like
create empty table based on definition of table, including column attributes , indexes defined in original table:
create table new_tbl orig_tbl;
the re-create created using same version of table storage format original table. select privilege required on original table.
documentation
if want re-create construction , data:
create table animals2 select * animals ;
and if want re-create construction (but not columns) without data:
create table animals2 select animal -- columns want animals false; -- , no info
mysql
No comments:
Post a Comment