查看某用户下所有序列
1
2
3
4
5
6
|
select sequence_owner, sequence_name, last_number from DBA_SEQUENCES where 1 = 1 and sequence_owner in ( 'INS' , 'OSSPAD' , 'MOBAPP' ) and sequence_name like '%SEQ_TB_BASE_PHOTO_REL%' order by last_number desc |
如何实现id自增长,主键生成策略?
因为Oracle中没有自增字段,要用sequence实现序列的自增长.
create sequence SEQ_TENANT_SYSTEM;(推荐使用);
注意:此时数据库id需要使用number类型:
alter table tbl_tenant_system modify id number not null;
uum-dao/src/main/java/com/coamctech/uum/dao/entity/TenantSystem.java
1
2
3
4
5
6
7
8
9
10
11
12
|
@Entity @ Table ( name = "TBL_TENANT_SYSTEM" , schema = UM_SCHEMA) public class TenantSystem extends BaseEntity { @Id @SequenceGenerator( name = "SEQ_TENANT_SYSTEM" , sequenceName= "SEQ_TENANT_SYSTEM" ,allocationSize=1) @GeneratedValue(strategy=GenerationType. SEQUENCE ,generator= "SEQ_TENANT_SYSTEM" ) private Integer id;//系统ID Integer 类型 @ Column ( name = "TENANT_ID" ) private Integer tenantId;//租户ID @ Column ( name = "SYSTEM_NAME" ) private String systemName;//系统名称 } |