default.sql
来自「简单的sql语句 数据与汇总。 高手多多指点。」· SQL 代码 · 共 53 行
SQL
53 行
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 + =
减小字号Ctrl + -
显示快捷键?