Answers to the mysterious Sybase ASE 'timestamp' datatype questions

匿名 (未验证) 提交于 2019-12-03 08:44:33

问题:

Eric Johnson ask the following questions in Aug 2010. "What is the mysterious 'timestamp' datatype in Sybase?

  1. What the heck is a timestamp?
  2. Does it have any relation at all to time or date?
  3. Can I convert it to a datetime?
  4. If its not a time or a date, what do you use it for?"

I attempted to answer the above post but this site would not accept a new answer due to the age of the original post. As the subject matter remains a FAQ amongst SAP/Sybase ASE professional, I have decided to re-post the original questions above and give hopefully some clear answers below.


Answer to Q#1 : 'What the heck is timestamp?'


Answer to Q#2 : 'Does it have any relation at all to time or date?'

No, the values in the 'Database' timestamp and page 'Local' timestamps do not reflect the actual date/time.


Answer to Q#3 : 'Can I convert it to a datetime?'

No, you cannot convert 'Database' timestamp or 'Local' timestamps of its pages to date/time value.


Answer to Q#4 : 'If its not a time or a date, what do you use it for?'


Further information, warnings and caveats:-

(1) The 'Database' and 'Local' timestamps are stored in 3 parts and is OS platform endianness dependent. e.g. 0xHHHH 0000 LLLLLLLL

  • 2-byte high-order - 0xHHHH
  • 2-byte filler - 0x0000
  • 4-byte low-order - 0xLLLLLLLL

(2) The user 'Table' timestamp is also stored in 3 parts but it is always in Big-endian orientation. e.g. 0x0000 HHHH LLLLLLLL

  • 2-byte filler - 0x0000
  • 2-byte high-order - 0xHHHH
  • 4-byte low-order - 0xLLLLLLLL

(3) The database timestamp is held in a in-memory system table dbtable of a given database (, which is created when a database is brought on line).

  • Note1 -'Table' timestamp column values are held just like other column values in the data and/or index pages of the database table, in which the timestamp column is defined.
  • Note2 - Be aware that querying the current database's 'Database' timestamp by SELECT @@dbts returns its hex representation, which is subjected to the OS platform's Endianness.
  • Note3 - In contrast, querying the 'Database' timestamp by DBCC dbtable (not recommended) returns its Big-endian hex representation, thus, it is platform independent.
  • WARNING - When the 'Database' timestamp of a given database approaches its maximum limit i.e. (0xFFFF, 0xFFFFFFFF), and it may take a decade or more to reach this point depending on the frequencies of insert/update operations within the database, ASE will throw a warning and no further insert/update will be possible - the only option is to export the data from all objects using BCP (plus stored procedures via sp_showtext), drop the database, create it again (with new near-zer 'Database' timestamp) and import the data (and stored procedures).

FYI - The above answers, hints & tips are authentic and accurate as I worked for Sybase and now work SAP, who owns the product ASE.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!