Home > Database > Mysql Tutorial > body text

MySQL中create table as 与like的区别分析_MySQL

WBOY
Release: 2016-05-27 13:45:28
Original
1335 people have browsed it

本文分析了MySQL中create table as 与like的区别。分享给大家供大家参考,具体如下:

对于mysql的复制相同表结构方法,有create table as 和create table like 两种,区别是什么呢?

代码如下:

create table t2 as select * from t1 where 1=2;

或者

代码如下:

limit 0;


as创建出来的t2表(新表)缺少t1表(源表)的索引信息,只有表结构相同,没有索引。

代码如下:

create table t2 like t1 ;


like 创建出来的新表包含源表的完整表结构和索引信息

二者的用途:

as用来创建相同表结构并复制源表数据

like用来创建完整表结构和全部索引

oracle支持as,也是只有表结构没有索引
oracle不支持like。

希望本文所述对大家MySQL数据库设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!