color:red

实验创建数据库及约束

 


create database 周凡实验.mdf

drop database 周凡实验

use master

if exists (select * from sysdatabases where name='周凡实验')

drop database 周凡实验
create database 周凡实验
on
(
name='周凡_data',
filename='D:\数据库文件\data\周凡_data.mdf'

)
log on
(
name='周凡_log',
filename='D:\数据库文件\data\周凡_log.ldf'

)
use 周凡实验
if exists (select * from sysobjects where name ='表一')

drop table 表一

create table 表一
(
uid int identity(1,1) not null, --标识自动增长
unmae varchar(15) ,
uemal varchar(30) not null
)
alter table 表一
add constraint dsa check ( unmae='男' or unmae='女')
--add constraint CK_Uemail check(uemal like '%@%')--电子邮件必须含有@符号
--add constraint df_unmae default ('男') for unmae

drop primary key uuuua check(uemal like '%@%'

delete 表一

insert into 表一(unmae,uemal) values ('男3','sc@3h')

print '成功'

 

posted on 2010-06-17 14:45  永不言弃program  阅读(257)  评论(0编辑  收藏  举报

导航

color:red