是否可以使日期時間數據類型的外鍵? 我試試這個,但我得到了錯誤信息: Msg 1776,Level 16,State 0,Line 1 引用表'penduduk'中沒有與外鍵'tgllahir'中的引用列表匹配的主鍵或候選鍵。 消息1750,級別16,狀態0,行1 無法創建約束。查看以前的錯誤。指向datetime的外鍵
我用這個查詢
父表:
create table penduduk (
no int identity(1,1),
noktp char(11) primary key,
nama varchar(20),
tgl_lahir datetime NOT NULL,
namahari varchar(20),
tgl int,
bulan int,
namabulan varchar(20),
tahun int,
umur int
)
CREATE TABLE tua(
noktp CHAR(11) PRIMARY KEY,
tgl_lahir datetime NOT NULL CONSTRAINT tgllahir FOREIGN KEY REFERENCES penduduk(tgl_lahir),
FOREIGN KEY(noktp) REFERENCES penduduk(noktp),
)
你引用的圖阿table.but tgl_lahir penduduk(tgl_lahir)未在penduduk表的主鍵 – Rohan 2013-05-09 12:59:17