SQL外键
创建外键约束
CREATE TABLE order_sample
(
orderid int PRIMARY KEY,
cust_id int FOREIGN KEY REFERENCES cuts_sample(cust_id) ON DELETE NO CASCADE
)
ON DELETE--用于控制尝试删除外键相关联的主表指向行时采取的操作
-NO ACTION
删除外键相关联的主表指向行时,报错
-CASCADE
删除外键相关联的主表指向行时,连带删除外键的所有行
-SET NULL
删除外键相关联的主表指向行时,把外键列设为空
-SET DEFAULT
删除外键相关联的主表指向行时,把外键列设为默认值
删除外键约束
ALTER TABLE order_sample
DROP CONSTRAINT [FK__order_sam__cust___0425A276]
添加外键
ALTER TABLE order_sample
ADD CONSTRAINT [FK__order_sam__cust___0425A276] FOREIGN KEY(cust_id) REFERENCES cuts_sample(cust_id) ON DELETE SET NULL
ON UPADTE 于ON DELETE方法一样
相关文档:
Standard Security:
"Data Source=Aron1;Initial
Catalog=pubs;User Id=sa;Password=asdasd;"
- or -
"Server=Aron1;Database=pubs;User
ID=sa;Pass ......
在sql查询分析器里面是不能直接运行cmd命令的
但是SQL给出了一个接口
--打开高级设置
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
--打开xp_cmdshell扩展存储过程
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE
首先 打开一些配置
然后执行你要运行cmd命令
exec master..xp_cmdshell 'net star ......
C#中以windows验证方式连接SQL server数据库的类。很多人连接数据库时可能都是网上查了然后就连了,对于参数的含义倒是没怎么在意,偶也是(呵呵),当然我们都注重结果嘛,可是这样不容易记忆每次连的时候都是上网查,感觉挺不方便,所以索性查了一下。~~~Integrated Security=True;表示在连接数据库进行身份验证时用wind ......
Five basic search conditions are summarized here:
1) Comparison test
2) Range test
3) Set membership test
4) Pattern matching test (Like)
The pattern matching test checks to see whether the data value in a column matches a specified pattern
% mathes any se ......
今天一个朋友问到这个问题,其实很好解决:
declare @dbname varchar(50)
declare c_database cursor for
select name from master.dbo.sysdatabas ......