这是建表和主键的sql语句。不知道是不是你想要的。
table_name t1,t2
CREATE TABLE [dbo].[t1] (
[t_i] [int] IDENTITY (1, 1) NOT NULL ,
[name] [char] (10) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[t2] (
[b_id] [int] IDENTITY (1, 1) NOT NULL ,
[brief] [char] (10) NULL ,
[t_id] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[t1] WITH NOCHECK ADD
CONSTRAINT [PK_t1] PRIMARY KEY NONCLUSTERED
(
[t_i]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[t2] ADD
CONSTRAINT [FK_t2_t1] FOREIGN KEY
(
[t_id]
) REFERENCES [dbo].[t1] (
[t_i]
)
GO