Set Primary Key,Unique Key,Foreign Key
Set to Primary Key ,Foreign Key , Unique Key Sql Server DataBase Table Fields Using Visual Studio
DEMO
Primary Key
CREATE TABLE [dbo].[country] (
Unique Key
Set to Primary Key ,Foreign Key , Unique Key Sql Server DataBase Table Fields Using Visual Studio
DEMO
Primary Key
CREATE TABLE [dbo].[country] (
[id] INT IDENTITY (1, 1) NOT NULL,
[name] VARCHAR (50) NOT NULL,
[country] VARCHAR (50) NOT NULL,
[amount] VARCHAR (50) NOT NULL,
CONSTRAINT [PK_country] PRIMARY KEY CLUSTERED ([id] ASC),
);
CREATE TABLE [dbo].[country] (
[id] INT IDENTITY (1, 1) NOT NULL,
[name] VARCHAR (50) NOT NULL,
[country] VARCHAR (50) NOT NULL,
[amount] VARCHAR (50) NOT NULL,
CONSTRAINT [PK_country] PRIMARY KEY CLUSTERED ([id] ASC),
UNIQUE NONCLUSTERED ([name] ASC)
);
Foreign Key
CREATE TABLE [dbo].[register] (
[username] VARCHAR (50) NOT NULL,
[password] VARCHAR (50) NOT NULL,
[country] VARCHAR (50) NOT NULL,
[name] VARCHAR (50) NOT NULL,
CONSTRAINT [FK_reg_country] FOREIGN KEY ([name]) REFERENCES [dbo].[country] ([name])
);
0 comments:
Post a Comment