1、把主键定义为自动增长标识符类型MySql在mysql中,如果把表的主键设为auto_increment类型,数据库就会自动为主键赋值。例如: 代码如下:create table customers(id int auto_increment primary key not null, name varchar(15));insert into customers(name) values(“name1”),(“name2”);select id from customers;以上sql语句先
sql语句查询数据库中的表名/列名/主键/自动增长值 —-查询数据库中用户创建的表 —-jsj01 为数据库名 select name tablename from jsj01..sysobjects where type=’U’ and name not in (‘dtproperties’) –查询表里的字段信息 —docs为表名 —- select * from syscolumns where id = object_id(‘docs’) —-查询数据库中所有类型 —-select na