---
title: "select into简单的表备份"
author: "hepx"
date: "2012-08-20T12:52:31Z"
tags: []
categories: ["数据库"]
slug: "select-into"
draft: false
lastmod: "2012-08-20T12:52:31Z"
id: 1638027
url: "https://hepx.iteye.com/blog/1638027"
---

1：MSSQL的用法：

select \[字段或\*] into  backTableName  from  sourceTableName   where \[条件]

注:MSSQL当没有backTableName时会自动创建表。

2：MYSQL的用法：

首先mysql不支持 select into这样的写法。官网的说明是用insert into ....select...如下：

insert into backTableName \[字段] select \[字段] from sourceTableName where\[条件] 

但这个写法有一个问题就是backTableName必须要先创建，而不是自动创建。想要创建可以用create table代替如下：

create table backTableName  select \[字段] from sourceTableName where \[条件]