SELECT INTO using Oracle(使用 Oracle SELECT INTO)
问题描述
我正在尝试使用 Oracle 执行 SELECT INTO.我的查询是:
I'm trying to do a SELECT INTO using Oracle. My query is:
SELECT * INTO new_table FROM old_table;
但我收到以下错误:
SQL Error: ORA-00905: missing keyword
00905. 00000 - "missing keyword"
知道有什么问题吗?
上面的标准行为应该是我原先认为的:然而,Oracle 用他们自己的 SQL 方言完全不同地实现了它插入 Oracle 文档...选择
The Standard behavior of the above should be as I originally thought: However Oracle implemented it totally differently in their own dialect of SQL Oracle Docs on Insert ... Select
推荐答案
如果 NEW_TABLE 已经存在,则 ...
If NEW_TABLE already exists then ...
insert into new_table
select * from old_table
/
如果你想根据 OLD_TABLE 中的记录创建 NEW_TABLE ...
If you want to create NEW_TABLE based on the records in OLD_TABLE ...
create table new_table as
select * from old_table
/
如果目的是创建一个新的但为空的表,则使用 WHERE 子句,其条件永远不会为真:
If the purpose is to create a new but empty table then use a WHERE clause with a condition which can never be true:
create table new_table as
select * from old_table
where 1 = 2
/
请记住,CREATE TABLE ... AS SELECT 仅创建一个与源表具有相同投影的表.新表没有原始表可能具有的任何约束、触发器或索引.那些仍然必须手动添加(如果需要).
Remember that CREATE TABLE ... AS SELECT creates only a table with the same projection as the source table. The new table does not have any constraints, triggers or indexes which the original table might have. Those still have to be added manually (if they are required).
这篇关于使用 Oracle SELECT INTO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Oracle SELECT INTO
基础教程推荐
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 无法解决整理冲突 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
