How to get product and variant details using sql query directly from commerce database?
Would like to know related tables also.
Not recommended and not documented. Why do you want to do it? :)
We don't disclose database schema, so basically it's blackbox to you. One of the reason is that maintaining database backward compatible is a very tedious task. Your script might stop working in the next update. Also you are missing all the cache.
What do you want to do with the product and variant details and why do you want to use direct database query? With proper fetching/caching strategy you can get adaquate, if not very good performance from well tested and well documented APIs.
@Janakiram : Just my 2 cents, I think you can achieve this using the Commerce API. You can use the API to traverse across the catalog and get all the information you require, you could leverage the data any way you want (Push it into a table in a DB, reports).
You can read from the commerce database, if you like. But you will be on your own, and you need to dig into the tables yourself, because the databases are not documented or supported.
That being said, I recommend that you query the APIs and push the necessary data to your client's BI database. You can do so regularly (with a scheduled job) or when changes occur (hook into content events).
The recipe 1.2 can be helpful