---
title: "高级建表SQL"
author: "loveseaside"
date: "2010-08-16T09:15:58Z"
tags: ["SQL"]
categories: ["数据库"]
slug: "sql"
draft: false
lastmod: "2010-08-16T09:15:58Z"
id: 738097
url: "https://loveseaside.iteye.com/blog/738097"
---

--建表AB 和已知表AA一样  
create table AB like AA  
\--把已知表AA中数据插入表AB  
Insert into AB(A1,A2) select A1,A2 from AA  
\--把已知表AA中符合条件的数据插入表AB  
Insert into AB(A1,A2) select A1,A2 from AA where A1='11'

--把表名AAA改成AA  
rename AAA to AA