dbeaver / dbeaver

Free universal database tool and SQL client
https://dbeaver.io
Apache License 2.0
38.31k stars 3.31k forks source link

Ability to select top 100 from a selected table in SQL Editor (custom command) #16074

Open match-gabeflores opened 2 years ago

match-gabeflores commented 2 years ago

Is your feature request related to a problem? Please describe. Say I have a query like below: image

I want to be able to select a table (store.subscription_event_types in the example) and right-click on it (or use some keyword) and have it execute a SELECT TOP 100 * FROM store.subscription_event_types.

In SSMS, I'm able to do something like this using a keyword shortcut and it's very handy to take a quick peek at a table.

Describe the solution you'd like After highlighting a table, execute a custom query (i think top N will be the most common) using either a context menu item or keyword shortcut. My preference is keyword shortcut so as to not bloat the context menu.

I'm not sure of the entire scope or implementation. I just have my simple use case which I currently use multiple times a day in SSMS.

Describe alternatives you've considered I don't know of any alternatives.

Additional context This is what I have in SSMS (no-addins). I use Top 100 and count(*) image

SSMSBoost (an extra add-in) uses a whole separate macro implementation that is very powerful and almost limitless but also much more complicated. https://www.ssmsboost.com/Features/ssms-add-in-simple-macros

LonwoLonwo commented 2 years ago

@match-gabeflores Thanks for the idea.

ShadelessFox commented 1 year ago

Hello @match-gabeflores,

Have you considered using the Templates feature?

image

https://user-images.githubusercontent.com/35821147/209560096-8c4baccc-87a7-43ec-bcf7-001c7731736f.mp4

match-gabeflores commented 1 year ago

hi @ShadelessFox , that's a SQL snippet feature which is different than what I'm asking.

See example below. Often times, there's a complicated query but I want to quickly analyze a table (or even a section of it). I can do so using the keyword shortcuts defined in my original post just by highlighting the table name. What happens behind the scenes, it runs the SELECT TOP 1000 * FROM <selected SQL> or whatever I define in the shortcut. Very convenient without having to type any SQL

https://user-images.githubusercontent.com/286903/213303224-17387a02-a9a2-4220-b005-3cb281a7374e.mp4

match-gabeflores commented 1 year ago

example 2 - selecting multiple tables with joins and iteratively getting count through each where condition

https://user-images.githubusercontent.com/286903/213304740-fd5711c0-bade-4c50-a7a2-c0d40e35d866.mp4

jorgeaponte commented 9 months ago

You can have a similar behavior by pressing F4 (you will see the selected table structure and the first 200 rows in the "Data" tab).

huzaifajks commented 3 months ago

@match-gabeflores did you find something that works? I am also desperately looking for this feature. Its very handy.

ShadelessFox commented 3 months ago

You can vote for the issue with the 👍🏻 emoji under the issue description to promote it to a higher priority.

Ryzzuh commented 3 days ago

bump