设为首页 加入收藏

TOP

sql中如果存在数据库或表则删除数据库或表(二)
2014-11-24 02:52:22 来源: 作者: 【 】 浏览:11
Tags:sql 如果 存在 数据库 删除
拿提成)
salesCompleted varchar(15) --销售完成时间
)
--房产咨询表;
if exists(select * from dbo.sysobjects where name='houseNews')
drop table houseNews
GO
create table houseNews(
houseNewId int not null, --自增长ID
houseNewTheme varchar(200) not null, --咨询主题
houseNewContent text, --咨询内容
houseNewDate varchar(15) --发布日期
)
--留言评论表
if exists(select * from dbo.sysobjects where name='Message')
drop table Message
GO
create table Message(
messageId int not null, --自增长ID
houseNumber varchar(15) not null, --房屋出租/出售编号(针对房屋编号留言)
messageContent varchar(200) not null, --留言内容
contact varchar(50), --联系方式
messageDate varchar(15) not null --留言时间
)
--添加约束
alter table userInfo add constraint pk_userId primary key (userId);
alter table userInfo add constraint DF_userRole default(0) for userRole;
alter table userInfo add constraint DF_registDate default(CONVERT(varchar(100), GETDATE(), 23)) for registDate;
alter table houseInfo add constraint pk_houseId primary key (houseId);
alter table employInfo add constraint pk_employId primary key (employId);
alter table employInfo add constraint DF_employPassWord default('888888') for employPassWord;
alter table employResult add constraint pk_employResultId primary key (employResultId);
alter table houseNews add constraint pk_houseNewId primary key (houseNewId);
alter table houseNews add constraint DF_houseNewDate default(CONVERT(varchar(100), GETDATE(), 23)) for houseNewDate;
alter table Message add constraint pk_messageId primary key (messageId);
alter table Message add constraint DF_messageDate default(CONVERT(varchar(100), GETDATE(), 23)) for messageDate;
首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Error: 701内存不足时使用DAC连接 下一篇禁用触发器的N种方法

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Sphinx : 高性能SQL (2025-12-24 10:18:11)
·Pandas 性能优化 - (2025-12-24 10:18:08)
·MySQL 索引 - 菜鸟教 (2025-12-24 10:18:06)
·Shell 基本运算符 - (2025-12-24 09:52:56)
·Shell 函数 | 菜鸟教 (2025-12-24 09:52:54)