set autotrace traceonly explain
Friday, June 15, 2007
More on Oracle execution plans
Another useful command in looking at Oracle execution plans is:
Query plans in Oracle (EXPLAIN PLAN)
Discovered this article when looking up how to view a query plan in Oracle.
Thursday, June 14, 2007
How to determine owners of Oracle tables
I recently needed to find out the schema names of certain Oracle tables that belonged to schemas other than the connecting user. This is because the four-part queries in SQL Server require the schema/owner name of the tables referenced. This query (run in SQL*Plus) lists the owners and names of all tables that can be seen by the connecting user:
SELECT OWNER, TABLE_NAME FROM ALL_TABLES;
A full reference for the ALL_TABLES view can be found here.
SELECT OWNER, TABLE_NAME FROM ALL_TABLES;
A full reference for the ALL_TABLES view can be found here.
Labels:
four part query,
linked server,
oracle,
schema,
SQL Server
Friday, June 1, 2007
Casting to NUMERIC/DECIMAL with E notation
Found this neat tidbit on some other guy's blog. Basically, NUMERICs/DECIMALs are exact numeric types and cannot contain the E notation in their representations. FLOATs are approximate numeric types and can contain the E notation. FLOATs can also be CASTed to NUMERIC/DECIMAL with no problems (other than a loss of precision).
For example, take the VARCHAR value X = '10000000E-2'. To cast it to NUMERIC/DECIMAL, use the following:
SELECT CAST(CAST(X AS FLOAT) AS NUMERIC(15, 4))...
You would obviously lose some precision if you cast with a NUMERIC field of less precision than what is represented by the contents of the VARCHAR value.
For example, take the VARCHAR value X = '10000000E-2'. To cast it to NUMERIC/DECIMAL, use the following:
SELECT CAST(CAST(X AS FLOAT) AS NUMERIC(15, 4))...
You would obviously lose some precision if you cast with a NUMERIC field of less precision than what is represented by the contents of the VARCHAR value.
Truncate the last n bytes of a file
Use FileStream.SetLength():
Dim strFile As String = "C:\Path\To\File.txt"
Dim fi As New FileInfo(strFile)
Dim fs As New FileStream(strFile, FileMode.Open, FileAccess.Write)
fs.SetLength(fi.Length - n)
fs.Flush()
fs.Close()
Dim strFile As String = "C:\Path\To\File.txt"
Dim fi As New FileInfo(strFile)
Dim fs As New FileStream(strFile, FileMode.Open, FileAccess.Write)
fs.SetLength(fi.Length - n)
fs.Flush()
fs.Close()
Thursday, May 24, 2007
Opening a Windows Explorer window in VB.NET
Use Process.Start:
Dim ps As New ProcessStartInfo("explorer")
ps.Arguments = "C:\Directory\to\open"
Process.Start(ps)
Dim ps As New ProcessStartInfo("explorer")
ps.Arguments = "C:\Directory\to\open"
Process.Start(ps)
Friday, May 18, 2007
.NET Regular Expression Escape Characters
\w - matches any word character
\W - matches any non-word character
\s - matches any whitespace character
\S - matches any non-whitespace character
\n - newline
\f - formfeed
\r - carriage return
\t - tab
\v - vertical tab
\0x0020 - space
\d - digit
^ - beginning of string
$ - end of string
\W - matches any non-word character
\s - matches any whitespace character
\S - matches any non-whitespace character
\n - newline
\f - formfeed
\r - carriage return
\t - tab
\v - vertical tab
\0x0020 - space
\d - digit
^ - beginning of string
$ - end of string
Subscribe to:
Posts (Atom)