Get the App
SLTechnology News&Howtos  ›  Database  › 

The replication method of mysql table structure

Shulou Source: shulou.com Published: 2022-05-31 21:07:15 09月30日 Update

This article mainly explains "the replication method of mysql table structure". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "the replication method of mysql table structure"!

We, especially oracle dbas, often copy the table structure through ctas, so the copied table will actually lose some properties of the table, not to mention the index. In mysql, replicating the table in this way will only get the general structure of the table.

Fortunately, mysql provides create table like commands to facilitate the replication of the table structure, so cut the crap.

Root@mysql 02:55:17 > use test

Database changed

Root@test 03:25:22 > create table T1 (an int,b int,key (a)) engine=myisam

Query OK, 0 rows affected (0.00 sec)

Root@test 03:25:49 > show create table T1G

* * 1. Row *

Table: t1

Create Table: CREATE TABLE `t1` (

`a`int (11) DEFAULT NULL

`b` int (11) DEFAULT NULL

KEY `a` (`a`)

) ENGINE=MyISAM DEFAULT CHARSET=gbk

1 row in set (0.00 sec)

Root@test 03:25:55 > create table T2 as select * from T1 where 1: 0

Query OK, 0 rows affected (0.00 sec)

Records: 0 Duplicates: 0 Warnings: 0

Root@test 03:26:16 > show create table T2G

* * 1. Row *

Table: t2

Create Table: CREATE TABLE `t2` (

`a`int (11) DEFAULT NULL

`b` int (11) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=gbk

1 row in set (0.00 sec)

Root@test 03:26:25 > create table T3 like T1

Query OK, 0 rows affected (0.00 sec)

Root@test 03:26:44 > show create table T3G

* * 1. Row *

Table: t3

Create Table: CREATE TABLE `t3` (

`a`int (11) DEFAULT NULL

`b` int (11) DEFAULT NULL

KEY `a` (`a`)

) ENGINE=MyISAM DEFAULT CHARSET=gbk

1 row in set (0.00 sec)

At this point, I believe that everyone on the "mysql table structure replication method" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Structure method replication method content practical learning practical deeper interest just command practicality actually attribute nonsense simple operation more friends index website Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi OPPO Reno MariaDB NVidia vpn