我想在表中建一个项,类型是int的,从1开始,自动增长
SQL语法怎么写啊

解决方案 »

  1.   

    alter table tb add id int identity
      

  2.   

    alter table 你的表 
    add id int identityidentity
    表示这个列是自增长的如果你这个表已经有自增长的列,那就不行的
      

  3.   

    不alter  
    这样行吗  在建表的时
    id int identity
      

  4.   

    在建表的时候,直接设置identity是可以的,回楼上
      

  5.   

    identity一般都是设置在整型的主键上,一般是id
      

  6.   

    create table c (
      id [int] IDENTITY(1,1) NOT NULL
    )
      

  7.   

    可以啊。create table tb(id int identity,col int.....)
      

  8.   

    create table 表名

    id int identity(1,1)  
    )(1,1)
    是表示,开始点以及自增长的幅度
      

  9.   

    要是再加一个主键设置,怎么加,先写identity还是primary primary key
      

  10.   

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_temp]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[t_temp]
    GOCREATE TABLE [dbo].[t_temp] (
    [id] [int] IDENTITY (1, 1) NOT NULL ,
    [ccc] [char] (10) COLLATE Chinese_PRC_CI_AS NULL 
    ) ON [PRIMARY]
    GO
    你可以先在sql管理器中建一个表,设计好自动增长,然后查看刚才操作的sql代码