How to create id with AUTO_INCREMENT on Oracle?

There is no such thing as “auto_increment” or “identity” columns in Oracle as of Oracle 11g. However, you can model it easily with a sequence and a trigger: Table definition: Trigger definition: UPDATE: IDENTITY column is now available on Oracle 12c: or specify starting and increment values, also preventing any insert into the identity column … Read more

How to do Select All(*) in linq to sql

Or just: In method syntax, with other operators: Essentially, you already are selecting all columns, the select then transforms that to the columns you care about, so you can even do things like:

ROW_NUMBER() in MySQ

I want the row with the single highest col3 for each (col1, col2) pair. That’s a groupwise maximum, one of the most commonly-asked SQL questions (since it seems like it should be easy, but actually it kind of isn’t). I often plump for a null-self-join: “Get the rows in the table for which no other … Read more

Equivalent of explode() to work with strings in MySQL

MYSQL has no explode() like function built in. But you can easily add similar function to your DB and then use it from php queries. That function will look like: Usage: The example above will return apple. I think that it will be impossible to return array in MySQL so you must specify which occurrence … Read more

DATEDIFF function in Oracle

In Oracle, you can simply subtract two dates and get the difference in days. Also note that unlike SQL Server or MySQL, in Oracle you cannot perform a select statement without a from clause. One way around this is to use the builtin dummy table, dual:

Oracle: If Table Exists

The best and most efficient way is to catch the “table not found” exception: this avoids the overhead of checking if the table exists twice; and doesn’t suffer from the problem that if the DROP fails for some other reason (that might be important) the exception is still raised to the caller: ADDENDUM For reference, … Read more

Cannot create an instance of OLE DB provider Microsoft.Jet.OLEDB.4.0 for linked server null

I have MS Sql server 2012, and Office 2013. This seems to be very finicky, so you may have to adjust to your particular versions. Download the Microsoft.ACE.OLEDB.12.0 for Windows, 64 bit version found here: https://www.microsoft.com/en-us/download/details.aspx?id=13255 Install it on your server. Check the user running SQL Server and make sure that user has access to the … Read more