首页 > 代码库 > Different between datetime and timestamp, and its setting
Different between datetime and timestamp, and its setting
According to the documentation, timestamp
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
Different between datetime and timestamp, and its setting
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。