1.主键和唯一性约束有什么区别呢?最好能举个例子说明一下 我总是觉得用了主键就是唯一性的约束 而唯一性的约束可以有很多 但是不能做主码...
2.谁有用代码写的 建立两个表 其中一个含有外健 我不要sql帮助里的 最好能自己写一个 谢谢你了 我实在有点蒙
3.有什么工具可以把用企业管理器生成的表 反编译成sql语句么?
谢谢
2.谁有用代码写的 建立两个表 其中一个含有外健 我不要sql帮助里的 最好能自己写一个 谢谢你了 我实在有点蒙
3.有什么工具可以把用企业管理器生成的表 反编译成sql语句么?
谢谢
-- 1
create table tb(id int not null primary key ,pid int REFERENCES ta(id))
---2
create table tb(id int not null primary key ,pid int ,FOREIGN KEY (pid) REFERENCES ta(id))
godrop table tb,ta
--右击数据库->生成数据角本
create table bb(bb_id int primary key foreign key references aa(aa_id) )
-- 主键的建立的同时会同时建立一个聚集索引,虽然一种浪费,因为我们很少用ID来确定范围,
--而用外键保持了数据的一致性 。
drop table tb1
if object_id('tb2') is not null
drop table tb2
go
create table tb1(a int primary key,name_ch varchar(10))
insert into tb1
select 1,'jl' union all
select 2,'rl'
select * from tb1
--go
create table tb2(b int primary key references tb1(a),age int )
create table tb2(b int primary key,age int,foreign key(b) references tb1(a))
insert into tb2
select 1,10 union all
select 2,20 select * from tb2