下面是5.1官方文档上面的说明
CREATE TABLE new_tbl LIKE orig_tbl;
The copy is created using the same version of the table storage format as the original table. The SELECT privilege is required on the original table.LIKE works only for base tables, not for views.CREATE TABLE ... LIKE does not preserve any DATA DIRECTORY or INDEX DIRECTORY table options that were specified for the original table, or any foreign key definitions.If the original table is a TEMPORARY table, CREATE TABLE ... LIKE does not preserve TEMPORARY. To create a TEMPORARY destination table, use CREATE TEMPORARY TABLE ... LIKE.大家有什么想法没?为什么会执行这么久,这么久会不会意味这以后线上操作别用like,直接用show create table t2,然后再copy进行create?
这个感觉一点思路都没有,而且现在还没有开始看源码,不好从源码入手查找。
CREATE TABLE new_tbl LIKE orig_tbl;
The copy is created using the same version of the table storage format as the original table. The SELECT privilege is required on the original table.LIKE works only for base tables, not for views.CREATE TABLE ... LIKE does not preserve any DATA DIRECTORY or INDEX DIRECTORY table options that were specified for the original table, or any foreign key definitions.If the original table is a TEMPORARY table, CREATE TABLE ... LIKE does not preserve TEMPORARY. To create a TEMPORARY destination table, use CREATE TEMPORARY TABLE ... LIKE.大家有什么想法没?为什么会执行这么久,这么久会不会意味这以后线上操作别用like,直接用show create table t2,然后再copy进行create?
这个感觉一点思路都没有,而且现在还没有开始看源码,不好从源码入手查找。
show create table t1;贴出来看一下。
CREATE TABLE NEWTT AS
SELECT * FROM TT WHERE
表结构信息我记得mysql high performance中说是保存在tablespace中的,既然保存在tablespace中,应该就不会这么慢
没有办法看源码,所以比较困惑。
CREATE TABLE new_tbl LIKE orig_tbl; 只不过是创建一个新的空表。它只是需要得到原表的create table语句中的相关信息,它会复制源表的字段和索引。你的慢是所有表都慢?还是仅某个表? 还是象大家猜的一样,包含大量数据的表?
包含了大量数据的,数据量应该是上千万的,我也觉得不应该和表的数据量有关系,所以产生了很多的怀疑。
按照左左的猜测,为什么show create table会非常快,即使数据量很大,也没有一点问题,这个问题感觉只能是阅读源码才能解释了