Is there a shortcut for SELECT * FROM?

蹲街弑〆低调 提交于 2019-11-26 04:53:53

问题


There are many useful shortcuts in psql console like \\d or \\l.
I wondering is there one for SELECT * FROM table_name?
I use this query often for learning purposes so it would be quite helpful not to have to write select * from ... all the time.


回答1:


There is a "shortcut" for SELECT * FROM in standard SQL, so you can use it in psql:

TABLE tablename;

This syntax shorthand can only be used with a limited range of clauses. The manual:

It can be used as a top-level command or as a space-saving syntax variant in parts of complex queries. Only the WITH, UNION, INTERSECT, EXCEPT, ORDER BY, LIMIT, OFFSET, FETCH and FOR locking clauses can be used with TABLE; the WHERE clause and any form of aggregation cannot be used.



来源:https://stackoverflow.com/questions/30275979/is-there-a-shortcut-for-select-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!