JAVA-系统-【2】-创建自增长的用户表

Posted on 2015-12-17 21:18  诸葛小北  阅读(345)  评论(0编辑  收藏  举报

【2】创建数据库表  用户表

自增

1、用户表结构  数据excel 表1

2、创建表

Create table A_USER(

    id number primary key,

    username varchar(100) not null,

    password varchar(200) ,

    logintime DATE,

    lastlogintime DATE,

    lastloginip varchar(50),

    loginnum number,

    remark varchar(200)

   

);
View Code

 

 

3、检查表存在

select * from A_USER

4、

因为Oracle不支持自动编号,所以还得创建一个SEQUENCE(序列)语句如下:
create sequence A_userlogin_seq increment by 1 start with 1 minvalue 1 maxvalue 9999999999999 nocache order;
5、插入数据测试自增
 


insert into a_user(id,userName,password) values(A_userlogin_seq.nextval,'tcm','123');

6、插入完整的数据

insert into a_user(id,userName,password,logintime,lastlogintime,lastloginip,loginnum,remark) 
values(A_userlogin_seq.nextval,'tcm','123',to_date('2015-12-17 21:01:01','yyyy-mm-dd hh24:mi:ss'),to_date('2015-12-17 21:01:02','yyyy-mm-dd hh24:mi:ss'),'10.10.1.111',9,'备注');
View Code

 

Copyright © 2024 诸葛小北
Powered by .NET 8.0 on Kubernetes