📄 default.sql
字号:
use northwind
go
exec sp_help customers
go
use northwind
go
select * from customers
go
create default df_cust as 'unknow'
go
/*创建默认*/
exec sp_bindefault df_cust,'customers.contactname'
go
/*绑定默认值到某列*/
/*上面连个步骤等价于下列代码
alter table customers
add constraint df_cust default 'unknow' for contactname
go
*/
/*
alter table customers
add hobby varchar(10) not null default 'unkonw'
go
*/
IF EXISTS (SELECT contactname FROM customers
WHERE contactname = 'unknow' )
DROP DEFAULT datedflt
GO
alter table customers
add constraint df_country default 'CH' for contactname
go
exec sp_help customers
go
alter table customers
add age int not null default(20)
go
alter table customers
add hobby varchar(10) not null default 'unkonw'
go
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -