Oracle 把一个表中的数据插入到另外一个表中
1.在oracle中可以用下面两种:01: create table newtable as select * from oldtable;//用于复制前未创建新表newtable不存
1.在Oracle中可以用下面两种:
01:
create table newtable as select * from oldtable;//用于复制前未创建新表newtable不存在的情况
02:
insert into newtable select * from oldtable;//已经创建了新表newtable 的情况
注意:第一种方式只是复制了表结构,,但是主键什么的并没有复制进去,所以用的时候要小心在意。
2.如果想简单快速的复制表结构,而不需要oldtable里面的数据,可以用下面的语句:
create table newtable as select * from oldtable where 1=2;(把数据过滤掉)
3.如过newtable 和oldtable的表结构不同,可以使用下面的方式:
create table newtable as select s.c1,s.c2 from oldtable s;
4.如果想重新命名newtable的列名:
在oracle中:
create table newtable(id,name1) as select s.c1,s.c2 from oldtable s;
或者
create table newtable as select s.c1 ,s.c2 from oldtable s;
在mysql中恐怕只能用第二种方式了。
5.如果是只需要把一部分的oldtable中的数据添加到newtable中。可以这样:
create table newtable as (select * from oldtable where ...);//加where过滤条件
6.最常见的情况是id列新表中要用,并且和旧表中的不同,使用下面的语句就可以了(我们可以重新建一个sequence)
create table yang(id,name) as select hibernate_sequence.nextval,t.ename from emp t;
7.要注意,导出表的时候不能用select...into语句。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]
