Home > Database > Mysql Tutorial > MySQL中表复制:create table like 与 create table as select_MySQL

MySQL中表复制:create table like 与 create table as select_MySQL

WBOY
Release: 2016-06-01 13:05:03
Original
1110 people have browsed it

代码如下:


CREATE TABLE A LIKE B

此种方式在将表B复制到A时候会将表B完整的字段结构和索引复制到表A中来。

代码如下:


CREATE TABLE A AS SELECT x,x,x,xx FROM B LIMIT 0

此种方式只会将表B的字段结构复制到表A中来,但不会复制表B中的索引到表A中来。这种方式比较灵活可以在复制原表表结构的同时指定要复制哪些字段,并且自身复制表也可以根据需要增加字段结构。

两种方式在复制表的时候均不会复制权限对表的设置。比如说原本对表B做了权限设置,复制后,表A不具备类似于表B的权限。

留空,接下来会探讨两种复制表的性能

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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template