要从别的表中选取数据创建如下的表(字段1和字段3的数据从别的表中来)
字段1 字段2 字段3 (字段1和字段2为表的主键)
a 1 s
a 2 d
a 3 s
a 4 d
b 1 s
b 2 d
b 3 s
b 4 s
b 5 d
b 6 d
c 1 a
c 2 s
c 3 a现在的问题是 创建表时 如何让字段2根据字段1来自动编号?
字段1 字段2 字段3 (字段1和字段2为表的主键)
a 1 s
a 2 d
a 3 s
a 4 d
b 1 s
b 2 d
b 3 s
b 4 s
b 5 d
b 6 d
c 1 a
c 2 s
c 3 a现在的问题是 创建表时 如何让字段2根据字段1来自动编号?
解决方案 »
- 想了解为什么这里0.99999 为什么必须是精确到小数点后5位
- 关于oracle的exp
- 求oralce中两个表比对问题
- pl/sql中F8编译存储过程的时候,pl/sql就死掉了,每次都这样,怎么解决?
- Oracle 可以实现像SQL Server 的合并复制功能吗?
- 我打算远程序连接一个ORACLE 数据库,在本地是否也要安装上ORACLE 的客 户端?
- OracleOraHome90Management Server问题
- 无法在 DLL oci.dll 中找到名为 OCIEnvCreate 的入口点。 这个怎么解决?
- SQL PLUS连数据库时出错:无法知道描述中的server name?
- oracle 集群功能 RAC关系
- SKIP LOCKED 出错
- 【求助】oracle10g在redhat5下的奇怪异常
select 字段1,
row_number()over(partition by 字段1 order by 字段1) 字段2,
字段3
from table_name;
insert into 表1 (字段1,字段2,字段3)
select 字段4,rownum,字段5 from 表2
alter table temp add constraint pk_temp primary key (字段1,字段2);
创建表时,对表里边字段1相同的值进行编号,编号都是从1开始,这个编号就是字段2的值
字段1 字段2 字段3 (字段1和字段2为表的主键)
a 1 s
a 2 d
a 3 s
a 4 d
b 1 s
b 2 d
b 3 s
b 4 s
b 5 d
b 6 d
c 1 a
c 2 s
c 3 a
row_number()over(partition by 字段1 order by 字段1) 字段2,
字段3
from table_name;
insert into 新表(字段1,字段2,字段3)
select 字段1,
row_number()over(partition by 字段1 order by 字段1) 字段2,
字段3
from 旧表;