Posts Tagged ‘Oracle’

I had a situation today, I accidentally executed SQL insert script twice. The bad thing was that the table had no primary key or unique key defined which may have stopped it from execution. Lesson: Not having Primary keys is a bad idea So, now I can not delete each row manually so I had […]

Finding highest or lowest number in a column is easy, you can do that with max() and min() SQL function. But I had recently been asked in an interview to write a query that could find the second highest value in a table column. Ooops, and I didn’t do well in that interview either.LOL Before […]

This is how you can create an oracle sequence Syntax CREATE SEQUENCE sequence_name MINVALUE VALUE MAXVALUE VALUE START WITH VALUE INCREMENT BY VALUE CACHE VALUE; A Demo CREATE SEQUENCE my_seq MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 INCREMENT BY 1 CACHE 20; — If you don’t provide MAXVALUE its default value is 99999999999999999999999999