Wanting to avoid paying licenses by doing your own implementation is perfectly legal and moral. Let's say we lived in a world where there were no Open Source RDBMS, and you didn't want to pay Oracle's license. There would nothing shady on you deciding to develop your own RDBMS.
Ignoring patents for a second you’re absolutely right. Where it gets hazy is if you copied Oracle’s query language because it was easier than designing your own.
To me the intention matters. If you copied it so that you could market that you work with existing software then I think you ought to be fine. If you copied it because designing a query language is hard then probably not.