How do I limit the number of rows returned by an Oracle query after ordering?

Starting from Oracle 12c R1 (12.1), there is a row limiting clause. It does not use familiar LIMIT syntax, but it can do the job better with more options. You can find the full syntax here. (Also read more on how this works internally in Oracle in this answer). To answer the original question, here’s the query: (For earlier Oracle versions, please … Read more

mysql Foreign key constraint is incorrectly formed error

I ran into this same problem with HeidiSQL. The error you receive is very cryptic. My problem ended up being that the foreign key column and the referencing column were not of the same type or length. The foreign key column was SMALLINT(5) UNSIGNED and the referenced column was INT(10) UNSIGNED. Once I made them both the same … Read more

How do you trouble shoot a “Data type mismatch in criteria expression” error in MS Access 2010?

The criteria expression is the part of the query containing the conditions, as in WHERE <condition>. Look at those specifically. The error message means you’re comparing two things (this equals that, or this less than that, etc.) that are of two different, and incompatible types (comparing a number to a string, for example). You can find … Read more

How do I import an SQL file using the command line in MySQL?

Try: Check MySQL Options. Note 1: It is better to use the full path of the SQL file file.sql. Note 2: Use -R and –triggers to keep the routines and triggers of original database. They are not copied by default. Note 3 You may have to create the (empty) database from MySQL if it doesn’t exist already and the exported SQL don’t contain CREATE DATABASE (exported … Read more

How to reset AUTO_INCREMENT in MySQL

You can reset the counter with: For InnoDB you cannot set the auto_increment value lower or equal to the highest current index. (quote from ViralPatel): Note that you cannot reset the counter to a value less than or equal to any that have already been used. For MyISAM, if the value is less than or equal to the maximum value … Read more

Oracle error : ORA-00905: Missing keyword

Unless there is a single row in the ASSIGNMENT table and ASSIGNMENT_20081120 is a local PL/SQL variable of type ASSIGNMENT%ROWTYPE, this is not what you want. Assuming you are trying to create a new table and copy the existing data to that new table