Default ORDER BY in database queries

Answered

Hello.

Please let me know if there's an opportunity to define a default order when viewing data from database.

When I'm choosing a table from Database Tool Window I want the data to be ordered by primary key in descending order.

In phpMyAdmin there is a TablePrimaryKeyOrder config option (https://docs.phpmyadmin.net/en/latest/config.html#cfg_TablePrimaryKeyOrder). Is there anything similar in PhpStorm?

Thanks,

13 comments
Comment actions Permalink

Hi there,

I could not find any existing tickets at https://youtrack.jetbrains.com/issues/DBE (DataGrip project is home for all such DB-related tickets)

Feel free to file Feature Request for this there at Issue Tracker.

0
Comment actions Permalink

Hi,

Can you find any solution for default ordering?

0
Comment actions Permalink

No one requested this yet: no solution yet. Feel free to submit a feature request at the addressed provided earlier describing your use case in details.

0
Comment actions Permalink

Didn't find a solution.

Created a feature request just now.

0
Comment actions Permalink

Hi, what about the default ordering in db viewer? it can be useful feature, i mean id desc 

 
0
Comment actions Permalink

Could you please elaborate? Do you want all the opened tables in given schema to be opened with e.g. first/id column sorted in descending order?

0
Comment actions Permalink

Yap, usually i need to look at  last records in database, and records has id like primary key.
now default request for view: 
SELECT t.*
FROM catalog.categories t
LIMIT 501

i need in all tables:
SELECT t.*
FROM catalog.categories t
ORDER BY id DESC
LIMIT 501


0
Comment actions Permalink

If  it can save settings for each views with last order and column position, after moving or and sorting, and will remember in new session, it will be perfect too.

0
Comment actions Permalink

Thanks! Checked that with DataGrip team: turns out they've implemented this just recently. You can test it in EAP build:

1
Comment actions Permalink

i need it for RubyMine, sorry my bad

0
Comment actions Permalink

Should be in RubyMine 2021.1 as well then.

0
Comment actions Permalink

I also wanted this but with an arbitrary column, on my case, created_at which is a timestamp, because my primary key is a UUID and it doesn't make sense to default sort by it.

0
Comment actions Permalink

please follow and vote for [the feature request], we consider to save sort order for a table rather then to complicate current behavior by adding special processing for UUIDs or timestamp fields.

1

Please sign in to leave a comment.