大家好,我想用一个旧的数据表,取出其中的几个字段建造一个新数据表,这个新数据表中还有一些新添加的字段,请问大家用sql语句可以完成这个功能吗?
比如我有一个旧表:oldtable有以下字段
id、amt、 date、store、infee、outfee……
现在我想取其中几个有用的字段组成一个新表:newtable,newtable 包括以下字段
id、amt、 date、Importdate
其中id amt date 是元数据表中的值,而ImportDate是导入新表的时间,请问大家这个sql语句该怎么写啊?
比如我有一个旧表:oldtable有以下字段
id、amt、 date、store、infee、outfee……
现在我想取其中几个有用的字段组成一个新表:newtable,newtable 包括以下字段
id、amt、 date、Importdate
其中id amt date 是元数据表中的值,而ImportDate是导入新表的时间,请问大家这个sql语句该怎么写啊?
select ot.id,ot.amt,ot.date,sysdate as importdate from oldtable;
select ot.id,ot.amt,ot.date,sysdate as importdate from oldtable ot;
可以先建表
create table newtable(id number,amt number, "date" date,Importdate date);
insert into newtable
select id,amt,"date",sysdate from oldtable;
create table a as select * from test t where 1=2;
如果你不向要数据 加上这个条件
想要 就加上WHERE
你要指定字段 则把 * 改成你要的字段