使用Oracle选择进入

我正在尝试使用Oracle进行SELECT INTO。我的查询是:


SELECT * INTO new_table FROM old_table;

但我收到以下错误:


SQL Error: ORA-00905: missing keyword

00905. 00000 -  "missing keyword"

任何想法有什么问题吗?


上面的标准行为应该是我最初的想法:但是,Oracle在自己的SQL方言“ 插入...选择”中以完全不同的方式实现了它 。


临摹微笑
浏览 788回答 3
3回答

白板的微信

如果NEW_TABLE已经存在,则...insert into new_table select * from old_table/如果要基于OLD_TABLE中的记录创建NEW_TABLE ...create table new_table as select * from old_table/如果目的是创建一个新的但空的表,则使用WHERE子句,其条件永远不能为真:create table new_table as select * from old_tablewhere 1 = 2/请记住,CREATE TABLE ... AS SELECT仅创建一个与源表具有相同投影的表。新表没有原始表可能具有的任何约束,触发器或索引。那些仍然必须手动添加(如果需要)。

肥皂起泡泡

select into在pl / sql中用于将变量设置为字段值。相反,使用create table new_table as select * from old_table

胡子哥哥

使用:create table new_table_name asselect column_name,[more columns] from Existed_table;例:create table deptasselect empno, ename from emp;如果表已经存在:insert into new_tablename select columns_list from Existed_table;
打开App,查看更多内容
随时随地看视频慕课网APP