一、设置id自增
mysql:
alter table ndzp_personal_goal change id id int not null auto_increment ;
sqlserver:
只能在创建表时候创建
alter table t_people add id int identity(1,1)
二、判断表是否存在
mysql:
SELECT count(1) information_schema.TABLES WHERE table_name ='表名';
sqlserver:
select count(*) from dbo.sysobjects where name= 'table_name';
三、判断字段是否存在
mysql:
select count(*) from information_schema.columns where table_name = '表名' and column_name = '字段名'
sqlserver:
select count(*) from syscolumns where id=object_id(‘table_name’) and name= 'column_name';