Thursday, October 18, 2018

create table with primary key

The issue with this you have to make sure PK_KEY that KEY has to be unique

USE [market_data]
GO

/****** Object:  Table [dbo].[FLKS]    Script Date: 10/18/2018 6:57:24 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[FLKS](
 [Volume] [numeric](9, 0) NULL,
 [Open] [decimal](18, 4) NULL,
 [High] [decimal](18, 4) NULL,
 [Low] [decimal](18, 4) NULL,
 [Close] [decimal](18, 4) NULL,
 [WAP] [decimal](18, 4) NULL,
 [Count] [numeric](9, 0) NULL,
 [dt] [datetime] NOT NULL,
 [EMA9] [decimal](18, 4) NULL,
 [EMA10] [decimal](18, 4) NULL,
 [EMA20] [decimal](18, 4) NULL,
 [EMA21] [decimal](18, 4) NULL,
 [EMA50] [decimal](18, 4) NULL,
 [EMA100] [decimal](18, 4) NULL,
 [EMA200] [decimal](18, 4) NULL
) ON [PRIMARY]
GO

ALTER TABLE dbo.[FLKS] ADD CONSTRAINT [PK_FLKS] PRIMARY KEY CLUSTERED
(
    dt DESC
)

No comments:

Post a Comment