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

sql server 定义主键

drop table father;
create table father(
 id int identity(1,1) primary key,
 name varchar(20) not null,
 age int not null
  
)
drop table mother;
create table mother(
 id int identity(1,1),
 name varchar(20) not null,
 age int not null,
 husband int not null
)
alter table mother
  add constraint FK_ID foreign key(husband) references father(id)
如果 在father中没能定义主键,
drop table father;
create table father(
 id int identity(1,1),   (未定义 primary key)
 name varchar(20) not null,
 age int not null
)
 则会报如下异常:
在被引用表 'father' 中没有与外键 'FK_ID' 的引用列的列表匹配的主键或候选键


相关文档:

SQL语句优化技术分析

最近几周一直在进行数据库培训,老师精湛的技术和生动的讲解使我受益匪浅。为了让更多的新手受益,我抽空把SQL语句优化部分进行了整理,希望大家一起进步。  
  一、操作符优化  
 1、IN 操作符   
  用IN写出来的SQL的优点是比较容易写及清晰易懂,这比较适合现代软件开发的风格。但是用IN的SQL性能总是比较 ......

SQL嵌套子查询


      使用子查询的原则
      1.一个子查询必须放在圆括号中。
      2.将子查询放在比较条件的右边以增加可读性。
      子查询不包含 ORDER BY 子句。对一个 SELECT 语句只能用一个 ORDER BY 子句,
&nb ......

解决SQL Server里sp_helptext输出格式错行问题

use Master 
go 
if object_id('SP_SQL') is not null 
  drop proc SP_SQL 
go 
create proc [dbo].[SP_SQL](@ObjectName sysname) 
as 
set nocount on ; 
declare @Print varchar(max) 
if exists(select 1 from syscomments  where ID=objec ......

PL/SQL实例分析

PL/SQL实例分析
第五章
1、PL/SQL实例分析
1)在【SQLPlus Worksheet】中直接执行如下SQL代码完成上述操作。(创建表)
―――――――――――――――――――――――――――――――

CREATE TABLE "SCOTT"."TESTTABLE" ("RECORDNUMBER" NUMBER(4) NOT NULL, "CURRENTDATE" DATE NOT NULL)
TABLESPACE "SYSTEM ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号