Development
Oracle partition size in Mb
by ivonko on Mar.17, 2010, under Development
Make connection as system or with user with “DBA” privilege
select partition_name,segment_name,
round(sum(bytes)/1024/1024,2) as Mb
from sys.dba_segments
where 1=1
and segment_name =’SOME_PARTITIONED_TABLE’ –table name
and tablespace_name = ‘USERS’ — tablespace name
and partition_name in (‘P16032010′,’P17032010’)
group by partition_name, segment_name
Oracle Timestamp Difference in seconds
by ivonko on Dec.23, 2009, under Development
select (TO_NUMBER(TO_CHAR(EndDate,’J’))-TO_NUMBER(TO_CHAR(CreateDate,’J’)))*86400 + (TO_NUMBER(TO_CHAR(EndDate,’SSSSS’))-TO_NUMBER(TO_CHAR(CreateDate,’SSSSS’))) AS “Delta (sec)” from table1
MSSQL function charindex-at-n-position
by ivonko on Dec.17, 2009, under Development
To find the charindex of an expression “_” in n position say 3rd occurancein a given word ‘xx_xxx_xx_xx’
Result : 10
SELECT dbo.fn_charIndex(‘_’,3,’ xx_xxx_xx_xx’)
—————————————————————
And the code for creating function:
Create function dbo.fn_charIndex(@Expression varchar(256),@nPos int,@Word varchar(2000))
returns int
as
begin
declare @ret int,@strt int
set @ret = 0
set @strt = 0
while not @strt = @npos
begin
select @ret = charindex(@Expression,@Word,@ret+1)
set @strt = @strt +1
end
return @ret
end
—————————————————————
Source: http://www.calsql.com/2009/10/function-charindex-at-n-position.html
Installing Oracle 11g on Ubuntu 8.04 x86
by ivonko on Nov.03, 2009, under Development
Инсталация на Oracle 11G no Ubuntu – link:
http://www.pythian.com/news/968/installing-oracle-11g-on-ubuntu-804-lts-hardy-heron
MSSQL Dates Difference
by ivonko on Sep.09, 2009, under Development
Returns the number of date and time boundaries crossed between two dates
SQL DATEDIFF Syntax
DATEDIFF ( DatePart , StartDate , EndDate )
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate =’2007-06-05′
SET @EndDate =’2007-08-05′
SELECT DATEDIFF(Year, @StartDate, @EndDate) AS NewDate
Return Value = 0 Year
SELECT DATEDIFF(quarter, @StartDate, @EndDate) AS NewDate
Return Value = 1 quarter
SELECT DATEDIFF(Month, @StartDate, @EndDate) AS NewDate
Return Value = 2 Month
SELECT DATEDIFF(dayofyear,@StartDate, @EndDate) AS NewDate
Return Value = 61 day
SELECT DATEDIFF(Day, @StartDate, @EndDate) AS NewDate
Return Value = 61 Day
SELECT DATEDIFF(Week, @StartDate, @EndDate) AS NewDate
Return Value = 9 Week
SELECT DATEDIFF(Hour, @StartDate, @EndDate) AS NewDate
Return Value = 1464 Hour
SELECT DATEDIFF(minute, @StartDate, @EndDate) AS NewDate
Return Value = 87840 minute
SELECT DATEDIFF(second, @StartDate, @EndDate) AS NewDate
Return Value = 5270400 second
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate =’2007-06-05‘
SET @EndDate =’2007-06-06‘
SELECT DATEDIFF(millisecond, @StartDate, @EndDate) AS NewDate
Return Value = 86400000 millisecond
Oracle sites
by ivonko on Mar.29, 2009, under Development
Перфектен сайт с обяснения и стъпка по стъпка инсталация и конфигуриране на Oracle ASM и др…
Ето го и сайта Manchev.org