oracle 想要依照现有的表建立一个没有数据的空表怎么办 create table new_table as select * from old_tab

[复制链接]
查看11 | 回复5 | 2010-9-12 23:59:15 | 显示全部楼层 |阅读模式
oracle 想要依照现有的表建立一个没有数据的空表怎么办 create table new_table as select * from old_tabble;
建立的是有内容的表。
诸位大哥,这种方法我知道。
我想问的是这种方法会不会遍历一遍数据库的表才给出结果。

回复

使用道具 举报

千问 | 2010-9-12 23:59:15 | 显示全部楼层
这个叫做复制表pl-sql语句create table 新表名 as select * from 被复制的表名 where 1=2 ; 上面的语句就是创建一个新标按你查出来的表的格式创建并复制内容只要where 后面的条件返回是false查出来的记录就为空,所以这样就达到了复制表结构而不复制内容
回复

使用道具 举报

千问 | 2010-9-12 23:59:15 | 显示全部楼层
create table new_table as select * from old_table where 1=0 ; where后面的条件可以随便加,就要结果非真即可,也就让返回的记录数为0行。
回复

使用道具 举报

千问 | 2010-9-12 23:59:15 | 显示全部楼层
create table new_table as select * from old_tabble where 1=2;加条件让它不返回记录就是的了
回复

使用道具 举报

千问 | 2010-9-12 23:59:15 | 显示全部楼层
摆渡
回复

使用道具 举报

千问 | 2010-9-12 23:59:15 | 显示全部楼层
create table new_table as select * from old_tabblewhere rownum<1;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行