博客
关于我
oracle复制一张表的数据到另一张表方法
阅读量:544 次
发布时间:2019-03-09

本文共 624 字,大约阅读时间需要 2 分钟。

复制到新表

create table 新表名称  as select * from 源表名称;

如将 test1中的数据复制到新表 test2中,可执行如下命令:

create table test2  as select * from test1;

如果只需要备份表结构,可执行如下命令:

create table test2 as select * from test1 where 1=0;

复制到已存在表

insert into 目标表 select * from 源表;

如将 test3中的数据复制到已存在表 test2中,可执行如下命令:

insert into test2 select * from test3;

扩展内容

同一张表中,将A字段的值赋给B字段

update table_name set B =  A;

将一张表的字段数据插入到另一张表的字段数据中

insert into 目标表(目标表字段1,目标表字段2,......)  select 源表字段1,源表字段1...... from  源表;

如将test1 name 和 age 字段的值插入test2 name 和 age 字段,可执行如下命令:

insert into test2(name,age) select name,age from test1;

SQL Server 备份单张表语句如下:

SELECT * into 目标表 FROM 源表;

转载地址:http://ffqiz.baihongyu.com/

你可能感兴趣的文章
MySQL 面试题汇总
查看>>
MySQL 面试,必须掌握的 8 大核心点
查看>>
MySQL 高可用性之keepalived+mysql双主
查看>>
MySQL 高性能优化规范建议
查看>>
mysql 默认事务隔离级别下锁分析
查看>>
Mysql--逻辑架构
查看>>
MySql-2019-4-21-复习
查看>>
mysql-5.6.17-win32免安装版配置
查看>>
mysql-5.7.18安装
查看>>
MySQL-Buffer的应用
查看>>
mysql-cluster 安装篇(1)---简介
查看>>
mysql-connector-java.jar乱码,最新版mysql-connector-java-8.0.15.jar,如何愉快的进行JDBC操作...
查看>>
mysql-connector-java各种版本下载地址
查看>>
mysql-EXPLAIN
查看>>
MySQL-Explain的详解
查看>>
mysql-group_concat
查看>>
MySQL-redo日志
查看>>
MySQL-【1】配置
查看>>
MySQL-【4】基本操作
查看>>
Mysql-丢失更新
查看>>