个语句用oracle怎么写

ydhxtf 2009-03-11 09:53:31
SELECT id=identity(int,1,1),* into #temp_audits FROM audits ORDER BY time

最好能一条实现,要不多条也可以
...全文
126 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
fxhyhyfzj 2009-03-12
  • 打赏
  • 举报
回复
路过学习中
ydhxtf 2009-03-11
  • 打赏
  • 举报
回复
好像语法有问题啊

SQL> create global temporary table temp_audits
2 as
3 select *,row_number() over(order by time) id from audits;
select *,row_number() over(order by time) id from audits
*
ERROR at line 3:
ORA-00923: FROM keyword not found where expected
cosio 2009-03-11
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ydhxtf 的回复:]
那么组合起来是不是可以这样写
create temporary table temp_audits
as
select * , row_number() over(order by time) id from audits
[/Quote]

OK的
ydhxtf 2009-03-11
  • 打赏
  • 举报
回复
那么组合起来是不是可以这样写
create temporary table temp_audits
as
select * , row_number() over(order by time) id from audits
Andy__Huang 2009-03-11
  • 打赏
  • 举报
回复
oracle的临时表这样用的
create temporary table tb
as
SELECT * FROM audits ORDER BY time
on commit presever rows;

create temporary table tb
as
SELECT * FROM audits ORDER BY time
on commit delete rows;
ydhxtf 2009-03-11
  • 打赏
  • 举报
回复
谢谢ls的,不过怎样把select的内容放进新的临时表呢
dawugui 2009-03-11
  • 打赏
  • 举报
回复
[Quote=引用楼主 ydhxtf 的帖子:]
SELECT id=identity(int,1,1),* into #temp_audits FROM audits ORDER BY time

最好能一条实现,要不多条也可以
[/Quote]

select * , row_number() over(order by time) id from audits
ydhxtf 2009-03-11
  • 打赏
  • 举报
回复
我的目的就是想给audits这张表按时间排序然后增加一个id列放在临时表中
ydhxtf 2009-03-11
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 ydhxtf 的回复:]
现在问题是这样,好像×里面包括零长度的字段,我用其他表是可以成功的,audits会报这个错,那该怎么解决呢

SQL> create global temporary table temp_audits
2  on commit preserve rows
3  as
4  select * from audits;
select * from audits
*
ERROR at line 4:
ORA-01723: zero-length columns are not allowed
[/Quote]
我找到原因是因为audits这张表有一个字段定义的时候用NULL,那么如何解决啊
cool_hnu 2009-03-11
  • 打赏
  • 举报
回复

create temporary table temp_audits
as
(select * , row_number() over(order by time) id from audits)
ydhxtf 2009-03-11
  • 打赏
  • 举报
回复
现在问题是这样,好像×里面包括零长度的字段,我用其他表是可以成功的,audits会报这个错,那该怎么解决呢

SQL> create global temporary table temp_audits
2 on commit preserve rows
3 as
4 select * from audits;
select * from audits
*
ERROR at line 4:
ORA-01723: zero-length columns are not allowed

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧