资源描述:
《数据库的SQL脚本代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、PowerDesigner设计的PDM模型生成数据库的SQL脚本(数据库名称为testDB),代码如下/*==============================================================*//*Databasename:流动人口管理系统PDM*//*DBMSname:MicrosoftSQLServer2000*//*Createdon:2008-1-410:51:46*//*===================================================
2、===========*/ifexists(select*fromodb.sysdatabaseswherename='TestDB')dropdatabaseTestDBgocreatedatabaseTestDBgouseTestDBgoifexists(select1fromsysindexeswhereid=object_id('TenancyBargin')andname='HouseHost_Contract_FK'andindid>0andindid<255)dropindexTenancyBargin.H
3、ouseHost_Contract_FKgoifexists(select1fromsysindexeswhereid=object_id('TenancyBargin')andname='Person_Contract_FK'andindid>0andindid<255)dropindexTenancyBargin.Person_Contract_FKgoifexists(select1fromsysindexeswhereid=object_id('TenancyHouse')andname='C_Tenancy_F
4、K'andindid>0andindid<255)dropindexTenancyHouse.C_Tenancy_FKgoifexists(select1fromsysobjectswhereid=object_id('HouseHost')andtype='U')droptableHouseHostgoifexists(select1fromsysobjectswhereid=object_id('PerMsg')andtype='U')droptablePerMsggoifexists(select1fromsyso
5、bjectswhereid=object_id('TenancyBargin')andtype='U')droptableTenancyBargingoifexists(select1fromsysobjectswhereid=object_id('TenancyHouse')andtype='U')droptableTenancyHousegoifexists(select1fromsysobjectswhereid=object_id('managerTab')andtype='U')droptablemanager
6、Tabgo/*==============================================================*//*Table:HouseHost*//*==============================================================*/createtableHouseHost(jIDchar(10)notnull,jnamechar(10)null,jsexbitnull,jborndaydatetimenull,telchar(50)null,
7、constraintPK_HOUSEHOSTprimarykey(jID))go/*==============================================================*//*Table:PerMsg*//*==============================================================*/createtablePerMsg(yidchar(18)notnull,namechar(8)null,sexbitnull,borndatetim
8、enull,positionchar(10)null,politicalchar(10)null,staytextnull,importantchar(20)null,studylevelchar(20)null,salarychar(20)null,socitytextnull,constraintPK_PERMS