db2 exists的使用

/*==============================================================*/
/* Database name:  国债兑付业务管理系统                                   */
/* DBMS name:      Sybase AS Enterprise 11.x                    */
/* Created on:     2005-1-4 9:12:06                             */
/*==============================================================*/




if exists (select 1
            from  sysindexes
            from  sysindexes
           where  id    = object_id('htd_bgzdfhz')
            and   name  = 'QueryByBj'
            and   indid > 0
            and   indid < 255)
   drop index htd_bgzdfhz.QueryByBj
go


if exists (select 1
            from  sysobjects 
            where  id = object_id('htd_bgzdfhz')
            and    type = 'U')
   drop table htd_bgzdfhz
go


if exists(select 1 from systypes where name='bs')
   execute sp_droptype bs
go


   


/*==============================================================*/
/* Table: htd_bgzdfhz                                           */
/*==============================================================*/
create table htd_bgzdfhz (
     gkdm                 nchar(10)                      not null,
     ssgkdm               nchar(10)                      not null,
     sbgkdm               nchar(10)                      not null,
     yhdm                 nvarchar(12)                   not null,
     zwnd                 nchar(8)                       not null,
     bjdm                 nvarchar(22)                   not null,
     bjnlj                numeric(18,2)                  null,
     lxdm                 nvarchar(22)                   not null,
     lxnlj                numeric(18,2)                  null,
     pdxz                 nchar(2)                       null,
     xsbz                 nchar(1)                       not null,
     constraint PK_HTD_BGZDFHZ primary key (bjdm, yhdm, gkdm, lxdm, zwnd, sbgkdm, xsbz, ssgkdm)
)
go




/*==============================================================*/
/* Index: QueryByBj                                             */
/*==============================================================*/
create index QueryByBj on htd_bgzdfhz (
bjdm,
yhdm,
gkdm,
zwnd
)
go








猜你喜欢

转载自blog.csdn.net/m0_37604866/article/details/80840943
今日推荐