《数据库的SQL脚本代码.doc》由会员分享,可在线阅读,更多相关《数据库的SQL脚本代码.doc(4页珍藏版)》请在金锄头文库上搜索。
1、PowerDesigner设计的PDM模型生成数据库的SQL脚本(数据库名称为testDB),代码如下/*=*/* Database name: 流动人口管理系统PDM */* DBMS name: Microsoft SQL Server 2000 */* Created on: 2008-1-4 10:51:46 */*=*/if exists (select * from odb.sysdatabases where name=TestDB)drop database TestDBgocreate database TestDBgouse TestDBgoif exists (selec
2、t 1 from sysindexes where id = object_id(TenancyBargin) and name = HouseHost_Contract_FK and indid 0 and indid 0 and indid 0 and indid 255) drop index TenancyHouse.C_Tenancy_FKgoif exists (select 1 from sysobjects where id = object_id(HouseHost) and type = U) drop table HouseHostgoif exists (select
3、1 from sysobjects where id = object_id(PerMsg) and type = U) drop table PerMsggoif exists (select 1 from sysobjects where id = object_id(TenancyBargin) and type = U) drop table TenancyBargingoif exists (select 1 from sysobjects where id = object_id(TenancyHouse) and type = U) drop table TenancyHouse
4、goif exists (select 1 from sysobjects where id = object_id(managerTab) and type = U) drop table managerTabgo/*=*/* Table: HouseHost */*=*/create table HouseHost ( jID char(10) not null, jname char(10) null, jsex bit null, jbornday datetime null, tel char(50) null, constraint PK_HOUSEHOST primary key
5、 (jID)go/*=*/* Table: PerMsg */*=*/create table PerMsg ( yid char(18) not null, name char(8) null, sex bit null, born datetime null, position char(10) null, political char(10) null, stay text null, important char(20) null, studylevel char(20) null, salary char(20) null, socity text null, constraint
6、PK_PERMSG primary key (yid)go/*=*/* Table: TenancyBargin */*=*/create table TenancyBargin ( BarginID char(10) not null, yid char(18) not null, TenancyID char(10) not null, jID char(10) not null, BarginMoney numeric(10,2) null, StartTime datetime null, StopTime datetime null, constraint PK_TENANCYBARGIN primary key (BarginID)go/*=*/* Index: Person_Contract_FK */*=*/create index Person_Contract_FK on TenancyBargin (yid)go/*=*/* Index: HouseHost_Contract_FK */*=