zoukankan      html  css  js  c++  java
  • Different between datetime and timestamp, and its setting

    According to the documentationtimestamp is a synonym for rowversion - it's automatically generated and guaranteed1 to be unique. datetime isn't - it's just a data type which handles dates and times, and can be client-specified on insert etc.

    Here is an example to use both datetime and timestamp in SQLSever . problem will happen, when you try to copy a datebase

    to a new database, then dates about the timestamp is not to copy........So what should we do about it. 

    USE [SWSK_YOSAN_161115]
    GO
    
    /****** Object:  Table [dbo].[T_TEST]    Script Date: 2017/01/27 11:55:09 ******/
    SET ANSI_NULLS ON
    GO
    
    SET QUOTED_IDENTIFIER ON
    GO
    
    SET ANSI_PADDING ON
    GO
    
    CREATE TABLE [dbo].[T_TEST](
        [JIGYOCD] [char](2) NOT NULL,
        [ORDERNO] [char](8) NOT NULL,
        [LASTUPDATEYMD] [datetime] NULL CONSTRAINT [DF_T_TEST_LASTUPDATEYMD]  DEFAULT (getdate()),
        [LASTUPDATEID] [varchar](20) NULL,
        [LASTUPDPGID] [varchar](20) NULL,
        [VERSIONNO] [timestamp] NULL,
     CONSTRAINT [PK_T_TEST] PRIMARY KEY CLUSTERED 
    (
        [JIGYOCD] ASC,
        [ORDERNO] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    
    SET ANSI_PADDING OFF
    GO
    SELECT [JIGYOCD]
    ,[ORDERNO]
    ,[LASTUPDATEYMD]
    ,[LASTUPDATEID]
    ,[LASTUPDPGID]
    ,[VERSIONNO]
    FROM [dbo].[T_TEST]
    GO
    
    
    

      

     
    Love it, and you live without it
  • 相关阅读:
    STR[#6]
    整数
    一些应该记住的东西(持续更新?再也不会更新了)
    退役后的续命杂谈
    51Nod 快速傅里叶变换题集选刷
    支配树学习笔记
    动态点分治入门随讲
    KD树小结
    HNOI2013 BZOJ3142 数列
    BZOJ2001 HNOI2010 城市建设
  • 原文地址:https://www.cnblogs.com/tomclock/p/6353699.html
Copyright © 2011-2022 走看看