How to store only time; not date and time?

You could try the INTERVAL DAY TO SECOND data type but it won’t save you any disk space … it is very suitable for this purpose though. create table t1 (time_of_day interval day (0) to second(0)); insert into t1 values (TO_DSINTERVAL(‘0 23:59:59’)); select date ‘2009-05-13’+time_of_day from t1; 11 bytes though.

Oracle SQL – max() with NULL values

max(end_dt) keep (dense_rank first order by end_dt desc nulls first) upd: SQL Fiddle Oracle 11g R2 Schema Setup: CREATE TABLE t (val int, s date, e date) ; INSERT ALL INTO t (val, s, e) VALUES (1, sysdate-3, sysdate-2) INTO t (val, s, e) VALUES (1, sysdate-2, sysdate-1) INTO t (val, s, e) VALUES (1, … Read more

How do you document your database structure? [closed]

MySQL allows comments on tables and rows. PostgreSQL does as well. From other answers, Oracle and MSSQL have comments too. For me, a combination of UML diagram for a quick refresher on field names, types, and constraints, and an external document (TeX, but could be any format) with extended description of everything database-related – special … Read more

Restore DB — Error RESTORE HEADERONLY is terminating abnormally.

You can check out this blog post. It had solved my problem. http://dotnetguts.blogspot.com/2010/06/restore-failed-for-server-restore.html Select @@Version It had given me following output Microsoft SQL Server 2005 – 9.00.4053.00 (Intel X86) May 26 2009 14:24:20 Copyright (c) 1988-2005 Microsoft Corporation Express Edition on Windows NT 6.0 (Build 6002: Service Pack 2) You will need to re-install to … Read more