Home Database Mysql Tutorial 如何对MySQL数据表进行复制、表结构复制_MySQL

如何对MySQL数据表进行复制、表结构复制_MySQL

Jun 01, 2016 pm 01:30 PM
how data sheet

bitsCN.com

如何对MySQL数据表进行复制、表结构复制

 

为大家介绍如何对MySQL进行复制、表结构复制,也可以分字段进行复制。也可以将一张表中的数据复制到另一张表当中。

 

1、复制表结构(语法 creata table 旧表 select * from 新表)

create table t1(  id int unsigned auto_increment primary key,  name varchar(32) not null default '',  pass int not null default 0 );
Copy after login

desc 查看表结构

如何对MySQL数据表进行复制、表结构复制_MySQL

创建表 t2 同时复制表 t1 表结构 create table t2 select * from t1;

desc t2 查看表结构

如何对MySQL数据表进行复制、表结构复制_MySQL

注意:两张的表字段结构一样,但是 主键 primary key 和 自增 auto_increment 没有了,所以这种方法不推荐大家使用,那如何才能创建出两张完全一样的表呢,办法肯定有的,如下面语句。

create  table  t2 like t1; 
Copy after login

这就可以创建一张 t2 和 t1 完全一样的表了。

2、指定字段复制表结构

语法: create table 新表 select 字段1,字段2 … from 旧表

3、复制表中数据

假设要把表 t1 中的数据全部复制到表 t2中insert  into  t2 select * from  t1;如果只想复制某个字段 insert  into  t2(字段1,字段2) select 字段1,字段2 from  t1;
Copy after login

 


bitsCN.com
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Data table compression technology in MySQL Data table compression technology in MySQL Jun 16, 2023 am 08:16 AM

MySQL is a common relational database that is a core component of many websites and applications. As the amount of data becomes larger and larger, how to optimize the performance of MySQL becomes particularly important. One of the key areas is the compression of data tables. In this article we will introduce the data table compression technology in MySQL. Compressed tables and non-compressed tables There are two types of data tables in MySQL: compressed tables and non-compressed tables. Uncompressed tables are MySQL's default table type, which use fixed-length row format to store data. This means data

mysql modify data table name mysql modify data table name Jun 20, 2023 pm 05:52 PM

MySQL modifies the data table: 1. First check all tables in the database, the code is: "SHOW TABLES;"; 2. Modify the table name, the code is: "ALTER TABLE old table name RENAME [TO] new table name;". 3. Check whether the table name is modified successfully. The code is: "SHOW TABLES;"

Is there a future for employment in clinical pharmacy at Harbin Medical University? (What are the employment prospects for clinical pharmacy at Harbin Medical University?) Is there a future for employment in clinical pharmacy at Harbin Medical University? (What are the employment prospects for clinical pharmacy at Harbin Medical University?) Jan 02, 2024 pm 08:54 PM

What are the employment prospects of clinical pharmacy at Harbin Medical University? Although the national employment situation is not optimistic, pharmaceutical graduates still have good employment prospects. Overall, the supply of pharmaceutical graduates is less than the demand. Pharmaceutical companies and pharmaceutical factories are the main channels for absorbing such graduates. The demand for talents in the pharmaceutical industry is also growing steadily. According to reports, in recent years, the supply-demand ratio for graduate students in majors such as pharmaceutical preparations and natural medicinal chemistry has even reached 1:10. Employment direction of clinical pharmacy major: After graduation, students majoring in clinical medicine can engage in medical treatment, prevention, medical research, etc. in medical and health units, medical research and other departments. Employment positions: Medical representative, pharmaceutical sales representative, sales representative, sales manager, regional sales manager, investment manager, product manager, product specialist, nurse

Data table DDL operation technology in MySQL Data table DDL operation technology in MySQL Jun 15, 2023 pm 07:55 PM

MySQL is a very popular open source relational database management system that supports complete DDL (data definition language) operations. DDL is a language used to define and manage various data objects in the database, including data tables, views, indexes, etc. It is very important for database administrators and developers to be proficient in DDL operation technology of data tables in MySQL. This article will introduce in detail the technology and methods of DDL operation of data tables in MySQL, and provide practical operation examples. 1. Create a data table. Creating a data table is in DDL.

How to calculate the average value of numeric columns in a data table using MySQL's AVG function How to calculate the average value of numeric columns in a data table using MySQL's AVG function Jul 24, 2023 pm 09:52 PM

Introduction to the method of using MySQL's AVG function to calculate the average value of numeric columns in a data table: MySQL is an open source relational database management system with a wealth of built-in functions to process and calculate data. Among them, the AVG function is a function used to calculate the average of a numeric column. This article will introduce how to use the AVG function to calculate the average value of numeric columns in a MySQL data table, and provide relevant code examples. 1. Create a sample data table First, we need to create a sample data table for demonstration. Suppose we have a file called

Data table reloading techniques in MySQL Data table reloading techniques in MySQL Jun 15, 2023 pm 11:28 PM

MySQL is an open source relational database management system. Its basic functions are excellent in database design, data storage and management. In MySQL, the data table is the most basic unit of data storage. In practical applications, data table reloading is a very common operating technique, which can help us improve the operating efficiency of the database and improve the stability of the system. This article will introduce this operation technique in detail from the concepts, principles and practical applications of data table overloading in MySQL. 1. What is data table overloading? Data table overloading is

How to download win10 image quickly How to download win10 image quickly Jan 07, 2024 am 11:33 AM

Recently, some friends reported how to download win10 image files. Because there are so many image files on the market, what should I do if I want to find a regular file to download? Today, the editor has brought you the link to download the image and the detailed solution steps. Let’s take a look at them together. win10 image quick download and installation tutorial download link >>> System Home Ghostwin101909 image 64-bit version v2019.11<<<>>>Win10 image 64-bit v2019.07<<<>>>Win10 image 32-bit v2019.07<< <1. Search through the Internet

How to clean temp folder How to clean temp folder Feb 22, 2024 am 09:15 AM

How to clean the temp folder As we use the computer, temporary files (temp files) will gradually accumulate. These temporary files are generated when we use the computer, such as cache files when browsing the web, temporary files during software installation, etc. Failure to clean the temp folder for a long time may occupy a large amount of disk space and affect the speed of the computer. Therefore, cleaning the temp folder regularly is a necessary step to maintain computer performance. Below, we will introduce some simple ways to clean the temp folder. Method 1: Manually clean t

See all articles