易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL Server 2005 UNIQUE 约束

SQL Server 2005:
ALTER Table Content_Node
ADD CONSTRAINT uc_TREECODE UNIQUE (TreeCode)
ALTER TABLE Content_Node
DROP CONSTRAINT uc_TREECODE
约束所在字段长度设为896,因为UNIQUE约束的最大键长度为 900 字节,而UNIQUE约束默认占有4字节。
参考:http://www.w3school.com.cn/sql/sql_unique.asp


相关文档:

sql—datediff 函数


 
DATEDIFF
   返回跨两个指定日期的日期和时间边界数。
   
   一、 语法 
   DATEDIFF ( datepart , startdate , enddate ) 
    
   二、参数
   datepar ......

SQL时间函数详解

1. 当前系统日期、时间
select getdate() 
2. dateadd 在向指定日期加上一段时间的基础上,返回新的 datetime 值
例如:向日期加上2天
select dateadd(day,2,'2004-10-15') --返回:2004-10-17 00:00:00.000
3. datediff 返回跨两个指定日期的日期和时间 ......

数据库命名规范(适用SQL Server)

设计原则
 
符号三大范式(每一列表达一个意思,每一行代表一个实例/每一行有唯一键/表内没有其它表的非主键信息)
 
每个表应该有的3个有用字段(记录创建或更新时间/记录创建者/记录版本)
 
避免保留字
 
表应避免可为空的列


 
命名规范
 

表名如Or ......

Linq to SQL DataContext Lifetime Management


Linq to SQL uses a DataContext to manage it's access to the database as well as tracking changes made to entities retrieved from the database. Linq to SQL has a persistent approach to managing its 'connection' to the database via this data context and it basically assumes that you use a single Dat ......

SQL中EXISTS的用法


比如在Northwind数据库中
有一个查询为
SELECT c.CustomerId, CompanyName
from Customers c
WHERE EXISTS(
SELECT OrderID from Orders o
WHERE o.CustomerID = cu.CustomerID)
这里面的EXISTS是如何运作呢?子查询返回的是OrderId字段,可是外面的查询要找的是CustomerID和CompanyName字段,这两个字段肯 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号