sqlServer基礎

CodeAgriculture發表於2013-04-20
exec sp_addtype schoolName, 'nvarchar(50)', 'not null'

exec sp_droptype schoolName

exec sp_help ac_test

create table ac_test1
(     Name varchar(30) null,
    Sex nchar(1) not null,
    Age Int    null
    )

Alter table ac_test1
alter constraint test_sex check (Sex=N'男'or Sex=N'女')

Alter table ac_test1
drop constraint test_sex

alter table ac_test1
alter column Sex nchar(1) not null;

insert into ac_test1 (name,sex,age) values('Mrs.Zhang',N'女',19);

insert into ac_test1 (name,age) values('Mrs.Zhang',19);

select * from ac_test1

delete from ac_test1

select len(sex),datalength(sex) from ac_test1

alter table ac_test1
add constraint default_sex default N'男' for Sex

exec sp_help ac_test1

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28699126/viewspace-758962/,如需轉載,請註明出處,否則將追究法律責任。

相關文章