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中IN,NOT IN,EXISTS,NOT EXISTS的用法和差别:
IN:确定给定的值是否与子查询或列表中的值相匹配。
IN 关键字使您得以选择与列表中的任意一个值匹配的行。
当要获得居住在 California、Indiana 或 Maryland 州的所有作者的姓名和州的列表时,就需要下列查询:
SELECT ProductID, ProductName from Northwind.dbo.Pro ......
大家打开这个链接可以看到很多数据库的连接方法。http://www.connectionstrings.com
这些数据库之间的数据交换就是这个贴子所要总结的内容。
(一)SQL Server之间
把远程数据库中的数据导入到本地数据库。
http://community.csdn.net/Expert/topic/5079/5079649.xml?temp=.7512018
http://community.csdn.net/Expert/ ......
簡體數據庫轉繁體數據庫的問題 拜托了
ALTER DATABASE DatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE DatabaseName COLLATE Chinese_Taiwan_Stroke_CI_AS
ALTER DATABASE DatabaseName SET MULTI_USER WITH ROLLBACK ......
1、说明:复制表(只复制结构,源表名:a 新表名:b) (Access可用)
法一:select * into b from a where 1 <>1
法二:select top 0 * into b from a
2、说明:拷贝表(拷贝数据,源表名:a 目标表名:b) (Access可用)
insert into b(a, b, c) select d,e,f from b;
3、说明:跨数据库之间表的拷贝(具体数据使用 ......
1) 选择最有效率的表名顺序(只在基于规则的优化器中有效):
ORACLE的解析器按照从右到左的顺序处理from子句中的表名,from子句中写在最后的表(基础表 driving table)将被最先处理,在from子句中包含多个表的情况下,你必须选择记录条数最少的表作为基础表。如果有3个以上的表连接查询, 那就需要选择交叉表(intersection ......