你是什么数据库啊,还有你的问题好象不是很明确!
select max 是选择这个字段中最大的值!

解决方案 »

  1.   

    “列名 数据类型 [null|not null][identity(起始值,步长值)]”
    其中indentity就可以实现自增长
      

  2.   

    sql server:
    create table tab_name(
    自动增长字段名 类型 IDENTITY (1, 1) NOT NULL,
    其它子段列;
    )
    oralce:创建一个序列
    create sequence 序列名
    increment 1
    start with 1 
    maxvalue 999999999 
    cycle;
    插入纪录时
    insert into 表名 values(序列名.nextval,列1值,列2值);
      

  3.   

    你的意思是每次添加记录的时候,id自动加一吧Connection con = getConnection();
    PreparedStatement pstmt = con.prepareStatement("select MAX(id) from mytable");
    ResultSet rs = pstmt.executeQuery();
    int iMaxId = rs.getInt("id");
    iMaxId++;
    然后把新的id和其他字段加到数据库里