很多时候只想复制表结构,而不需要数据,很多人这样:
create table new_table select * from old_table where 1=2
这样的问题是主键等需要重新建立
今天试了下,推荐个新方法:
create table new_table select * from old_table where item_id='**';
delete from new_table where item_id='**'
即在目标表中查询得到一条数据,之后删除,就可以完整复制目标表结构了。