Which is the “best” data access framework/approach for C# and .NET?

I think LINQ to SQL is good for projects targeted for SQL Server. ADO.NET Entity Framework is better if we are targeting different databases. Currently I think a lot of providers are available for ADO.NET Entity Framework, Provider for PostgreSQL, MySQL, esql, Oracle and many other (check http://blogs.msdn.com/adonet/default.aspx). I don’t want to use standard ADO.NET … Read more

How to get table comments via SQL in Oracle?

Since 10g Oracle doesn’t immediately drop tables when we issue a DROP TABLE statement. Instead it renames them like this BIN$IN1vjtqhTEKcWfn9PshHYg==$0 and puts them in the recycle bin. This allows us to recover tables we didn’t mean to drop. Find out more. Tables in the recycle bin are still tables, so they show up in … Read more

Prevent duplicate values in LEFT JOIN

I like to call this problem “cross join by proxy”. Since there is no information (WHERE or JOIN condition) how the tables department and contact are supposed to match up, they are cross-joined via the proxy table person – giving you the Cartesian product. Very similar to this one: Two SQL LEFT JOINS produce incorrect … Read more

Oracle equivalent of Postgres’ DISTINCT ON?

The same effect can be replicated in Oracle either by using the first_value() function or by using one of the rank() or row_number() functions. Both variants also work in Postgres. first_value() select distinct col1, first_value(col2) over (partition by col1 order by col2 asc) from tmp first_value gives the first value for the partition, but repeats … Read more