Re: psql \d option list overloaded
Re: psql \d option list overloaded
От:
Rod Taylor <pg@rbt.ca>
Дата:
> Anything other than simple, short commands is a waste, IMHO. I can easily > remember SHOW DATABASES and SHOW TABLES and DESC
Re: psql \d option list overloaded
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Greg Stark writes: > So for example: > \describe table foo => \dt foo > \describe index foo => \di foo > \describe aggregate foo => \da foo > \describe operator foo => \do foo It doesn't seem to me that this buys much except verboseness, though. ISTM there are three fundamental problems with \d and friends: 1. Some people have a hard time remembering the commands.2. Some people aren't using psql.3. psql keeps breaking across backend versions because the needed commands change. I don't see a lot of value in addressing just one of these problem areas, when we could instead do something that addresses all three. regards, tom lane
Re: psql \d option list overloaded
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Peter Eisentraut writes: > Tom Lane wrote: >> 2. Some people aren't using psql. > I don't see why this is an issue. People not using psql are either > using a GUI, which presumably supports plenty of "show" and "describe" > functionality, or they're writing their own program, in which case it > doesn't really matter how short or easy to remember the commands are. But this interacts with point 3 (psql breaks on every new backend version). It's not desirable to have every GUI and large custom program implementing its own set of metadata inquiry commands: they all have to go through the same update pain as psql. Perhaps if people start to rely on information_schema for those things, life will get better, but I'm unconvinced that will happen. psql itself certainly hasn't moved in that direction. regards, tom lane
psql \d option list overloaded
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
D. Dante Lorenso wrote:
> > When I started with PostgreSQL and MySQL, MySQL was far easier
> > to use
>
> I started with MySQL and it WAS easier to use. It was easier because
> the manual essentially reads:
>
> -- we didn't implement anything complicated that's why
> -- we are fast.
>
> The only SQL customizations that MySQL has that I really miss in PostgreSQL
> are the commands:
>
> SHOW DATABASES;
> SHOW TABLES;
> DESC table;
>
> That was ubber simple to do in MySQL. To this day, I have trouble with
> that in PostgreSQL. I'm constantly doing:
>
> psql> \?
> psql> help;
> ERROR: syntax error at or near "help" at character 1
> psql> \h
> ...
> * damnit, that's not it...*
> psql> \?
> psql> \d
> * ok, now which flag do I use for tables vs functions..etc?*
>
> I finally figure it out, I just end up forgetting again later. I still
> have no clue how I'd find the same data without using psql. In MySQL
> I can run those queries from PHP, PERL...etc. I know you can find that
> data in system tables in PostgreSQL, but I don't wanna muck around with
> all that. I just wanna do something as simple as MySQL.
[ Moved to hackers.]
I am starting to agree that our \d* handling is just too overloaded.
Look at the option list from \?:Informational \d [NAME] describe table, index, sequence, or view \d{t|i|s|v|S} [PATTERN] (add "+" for more detail) list tables/indexes/sequences/views/system tables \da [PATTERN] list aggregate functions \dc [PATTERN] list conversions \dC list casts \dd [PATTERN] show comment for object \dD [PATTERN] list domains \df [PATTERN] list functions (add "+" for more detail) \dg [PATTERN] list groups \dn [PATTERN] list schemas \do [NAME] list operators \dl list large objects, same as \lo_list \dp [PATTERN] list table access privileges \dT [PATTERN] list data types (add "+" for more detail) \du [PATTERN] list users \l list all databases (add "+" for more detail) \z [PATTERN] list table access privileges (same as \dp)
Can anyone remember all those? With the single-letter options, once the
list got too long, we started encouraging long option names. It seems
the same is true of \d.
I like the idea of adding a new syntax to show that information using
simple SQL command syntax, and putting it in the backend so all
applications can access it. I know we have information schema, and
maybe that can be used to make this simpler.
-- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Re: psql \d option list overloaded
От:
"Alex J. Avriette" <alex@posixnap.net>
Дата:
On Sat, Jan 03, 2004 at 08:25:21PM -0500, Bruce Momjian wrote: > > I finally figure it out, I just end up forgetting again later. I still > > have no clue how I'd find the same data without using psql. In MySQL > > I can run those queries from PHP, PERL...etc. I know you can find that > > data in system tables in PostgreSQL, but I don't wanna muck around with > > all that. I just wanna do something as simple as MySQL. > > [ Moved to hackers.] > > I am starting to agree that our \d* handling is just too overloaded. > Look at the option list from \?: > I like the idea of adding a new syntax to show that information using > simple SQL command syntax, and putting it in the backend so all > applications can access it. I know we have information schema, and > maybe that can be used to make this simpler. Bruce, while I agree with you about \d (and all its children), as well as the querying we talked about on irc, I disagree with the notion of a "SHOW DATABASES" query. This is one of the things that irritates me about mysql is the pseudo-sql that everyone has come to accept (through learning sql on mysql) as "sql". Things such as the '#' comments, and the various SHOW DATABASES, I feel, detract from the "look and feel" of the database. That look and feel is one of the reasons I am so loyal to postgres (and indeed why some people are so loyal to mysql). It doesn't make sense to create pseudo-sql, when all you're abstracting is function-macros. I think the backslash syntax is fine. If you really wanted to change it, you might consider a different syntax for it. Many of us are familiar with slash/bang/colon/backslash commands in interfacing with the programs we use regularly (vi, shells, irc clients). Why not a /functions as a long syntax for \df? Would there be a direct problem using the forward slash as a command indicator? This way you could give people like the original poster something they were looking for, eg: /functions /databases and what I was looking for: /functions timestamp It also allows us a lot more freedom in changing the syntax, as the expression of the commands is english (or, pick your language). I seem to recall Neil mentioning to me that was a problem with internationalization, but that's over my head. I don't have any particular allegiance to the forward slash over anything else. My chief concern is that what we're abstracting here are macros, and as such, they should not be treated as sql. Because they aren't sql. If you want to find out how to show the databases in sql, use psql -E. Alex -- alex@posixnap.net Alex J. Avriette, Solaris Systems Masseur "I ... remain against the death penalty because I feel that eternal boredom with no hope of parole is a much worse punishment than just ending it all mercifully with that quiet needle." - Rachel Mills, NC Libertarian Gubernatorial Candidate
Re: psql \d option list overloaded
От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Bruce Momjian wrote: > I am starting to agree that our \d* handling is just too overloaded. > Look at the option list from \?: > Can anyone remember all those? Yes. > I like the idea of adding a new syntax to show that information using > simple SQL command syntax, and putting it in the backend so all > applications can access it. I know we have information schema, and > maybe that can be used to make this simpler. That's right.
Re: psql \d option list overloaded
От:
"Alex J. Avriette" <alex@posixnap.net>
Дата:
On Sun, Jan 04, 2004 at 07:59:02PM -0600, D. Dante Lorenso wrote: > Anything other than simple, short commands is a waste, IMHO. I can easily > remember SHOW DATABASES and SHOW TABLES and DESC
Re: psql \d option list overloaded
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Alex J. Avriette wrote: > On Sun, Jan 04, 2004 at 07:59:02PM -0600, D. Dante Lorenso wrote: > > > Anything other than simple, short commands is a waste, IMHO. I can easily > > remember SHOW DATABASES and SHOW TABLES and DESC
Re: psql \d option list overloaded
От:
Tommi Maekitalo <t.maekitalo@epgmbh.de>
Дата:
Am Sonntag, 4. Januar 2004 20:13 schrieb Alex J. Avriette: > On Sat, Jan 03, 2004 at 08:25:21PM -0500, Bruce Momjian wrote: > > > I finally figure it out, I just end up forgetting again later. I still ... > > /functions > /databases > ... Long options sounds really good. It is like GNU-tools. A single - for single character options and a double -- for long options. Ah - a single \ for short options in postgresql and a double \\ for long? What do you think? -- Dr. Eckhardt + Partner GmbH http://www.epgmbh.de
Re: psql \d option list overloaded
От:
Tommi Maekitalo <t.maekitalo@epgmbh.de>
Дата:
Hi, > > 2) (using information schema ... little better) > > SELECT table_name FROM information_schema.tables WHERE table_schema > = 'public'; > > or ... > ... I just looked at the information_schema. It is a very nice feature, but difficult to use in psql. I just wanted to see, what I can find here. After trying and rtfm I ended in '\d information_schema.*'. I get a very large page wich is quite unreadable. '\d' is normally very usable. It would be better not to show the view-definition. What if \d on views just show the column, type and attribute. \d+ would show the full view-definition. Tommi -- Dr. Eckhardt + Partner GmbH http://www.epgmbh.de
Re: psql \d option list overloaded
От:
Kevin Brown <kevin@sysexperts.com>
Дата:
Alex J. Avriette wrote: > On Sun, Jan 04, 2004 at 07:59:02PM -0600, D. Dante Lorenso wrote: > > > Anything other than simple, short commands is a waste, IMHO. I can easily > > remember SHOW DATABASES and SHOW TABLES and DESC
Re: psql \d option list overloaded
От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Kevin Brown wrote: > Every database engine is different, but in the case of PG it makes > sense to adopt the best methods we can find. A consistent and easy > to remember way of showing the various entities in psql (at the very > least) would be of great advantage. It's something that MySQL gets > right. As it turns out, we already have "SHOW" in psql and it's used > for something else. So we might instead use something else (e.g. > "VIEW") instead. What is wrong with SELECT * FROM information_schema.tables; ? If it's too much to type, put information_schema in the path. This syntax has the advantage that you can use qualifications and other SQL features. And you can build customized views on top of it. Does SHOW TABLES or whatever it might be called support that?
Re: psql \d option list overloaded
От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Tom Lane wrote: > 2. Some people aren't using psql. I don't see why this is an issue. People not using psql are either using a GUI, which presumably supports plenty of "show" and "describe" functionality, or they're writing their own program, in which case it doesn't really matter how short or easy to remember the commands are.
Re: psql \d option list overloaded
От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Dennis Björklund wrote: > > What is wrong with > > > > SELECT * FROM information_schema.tables; > > The result is very hard to read since it's so much of it (try column > instead of tables). The \xx commands do some nice formatting you > don't get from the above. This is an interesting point to remember for those that are advocating pushing psql's queries into the backend. psql's queries are optimized for monospaced text screens of limited size. Unless someone else is writing a command-line client, there would be little reuse effect, because any given application will have different display requirements. (Another problem with pushing psql's queries into the backend is that much of the output that psql makes is not a single table. Sometimes there is more than one table, or the information is in the table footers. It'd be quite complicated to make the backend produce those kinds of displays.)
Re: psql \d option list overloaded
От:
Robert Treat <xzilla@users.sourceforge.net>
Дата:
On Saturday 10 January 2004 19:16, Jon Jensen wrote:
> On Sat, 10 Jan 2004, Tom Lane wrote:
> > ISTM there are three fundamental problems with \d and friends:
> >
> > 1. Some people have a hard time remembering the commands.
> > 2. Some people aren't using psql.
> > 3. psql keeps breaking across backend versions because the
> > needed commands change.
> >
> > I don't see a lot of value in addressing just one of these problem
> > areas, when we could instead do something that addresses all three.
>
> I agree, at least for #2 and #3. But I just don't understand #1. Anything
> is hard to remember when you're just starting to learn it. But it's still
> faster to type \? then \dt than it is to type "show tables". And
> "show tables" is hard (relatively speaking) for me to remember because I'm
> used to psql's way of doing things, since I mostly use it.
>
I'd second this point; I've certainly stumbled over the "show" syntax when
trying to get anything other than tables in mysql.
Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL
Re: psql \d option list overloaded
От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Tom Lane wrote:
> But this interacts with point 3 (psql breaks on every new backend
> version). It's not desirable to have every GUI and large custom
> program implementing its own set of metadata inquiry commands: they
> all have to go through the same update pain as psql. Perhaps if
> people start to rely on information_schema for those things, life
> will get better, but I'm unconvinced that will happen. psql itself
> certainly hasn't moved in that direction.
IIRC, the two killers in psql compatibility have been outer joins and
schemas. I don't see how we could have avoided that, except with
highly specialized and static (parameter-less) commands. There have
been additional minor issues, but I suppose we could have avoided those
if we had cared to do so at all.
Several people have in the past proposed to keep psql backward
compatible, even if only by means of
if (version =x) { ...
}
else if (version = y) { ...
}
(which would be fine by me), but apparently no one has felt pressed
enough yet.
Re: psql \d option list overloaded
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
I have added this psql backslash discussion to TODO.detail.
---------------------------------------------------------------------------
Peter Eisentraut wrote:
> Tom Lane wrote:
> > But this interacts with point 3 (psql breaks on every new backend
> > version). It's not desirable to have every GUI and large custom
> > program implementing its own set of metadata inquiry commands: they
> > all have to go through the same update pain as psql. Perhaps if
> > people start to rely on information_schema for those things, life
> > will get better, but I'm unconvinced that will happen. psql itself
> > certainly hasn't moved in that direction.
>
> IIRC, the two killers in psql compatibility have been outer joins and
> schemas. I don't see how we could have avoided that, except with
> highly specialized and static (parameter-less) commands. There have
> been additional minor issues, but I suppose we could have avoided those
> if we had cared to do so at all.
>
> Several people have in the past proposed to keep psql backward
> compatible, even if only by means of
>
> if (version =x) {
> ...
> }
> else if (version = y) {
> ...
> }
>
> (which would be fine by me), but apparently no one has felt pressed
> enough yet.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
-- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Re: psql \d option list overloaded
От:
Mark Kirkwood <markir@paradise.net.nz>
Дата:
Couldn't agree more - syntax like SHOW TABLES; is inituitive and somehow "right" - [chuckles] - Mysql does not have *everything* wrong! regards Mark Bruce Momjian wrote: >I like the idea of adding a new syntax to show that information using >simple SQL command syntax, and putting it in the backend so all >applications can access it. I know we have information schema, and >maybe that can be used to make this simpler. > > >
Re: psql \d option list overloaded
От:
"D. Dante Lorenso" <dante@lorenso.com>
Дата:
Alex J. Avriette wrote: >On Sat, Jan 03, 2004 at 08:25:21PM -0500, Bruce Momjian wrote: > > >>>I finally figure it out, I just end up forgetting again later. I still >>>have no clue how I'd find the same data without using psql. In MySQL >>>I can run those queries from PHP, PERL...etc. I know you can find that >>>data in system tables in PostgreSQL, but I don't wanna muck around with >>>all that. I just wanna do something as simple as MySQL. >>> >>> >>[ Moved to hackers.] >> >>I am starting to agree that our \d* handling is just too overloaded. >>Look at the option list from \?: >> >> >>I like the idea of adding a new syntax to show that information using >>simple SQL command syntax, and putting it in the backend so all >>applications can access it. I know we have information schema, and >>maybe that can be used to make this simpler. >> >> >Bruce, while I agree with you about \d (and all its children), as well >as the querying we talked about on irc, I disagree with the notion of a >"SHOW DATABASES" query. This is one of the things that irritates me >about mysql is the pseudo-sql that everyone has come to accept ... It doesn't >make sense to create pseudo-sql, when all you're abstracting is function-macros... > Anything other than simple, short commands is a waste, IMHO. I can easily remember SHOW DATABASES and SHOW TABLES and DESC
Re: psql \d option list overloaded
От:
Thomas Swan <tswan@idigx.com>
Дата:
Bruce Momjian wrote: >Alex J. Avriette wrote: > > >>On Sun, Jan 04, 2004 at 07:59:02PM -0600, D. Dante Lorenso wrote: >> >> >> >>>Anything other than simple, short commands is a waste, IMHO. I can easily >>>remember SHOW DATABASES and SHOW TABLES and DESC
Re: psql \d option list overloaded
От:
Andrew Dunstan <andrew@dunslane.net>
Дата:
Thomas Swan wrote: > >The \d* commands work from psql but not from anywhere else. Try >getting the information from a PHP script by sending a "\dS" query. It >doesn't work. If the same queries were stored in the backend and >referenced by psql and also could be referenced by other scripts, this >would be a good thing and keep the work centralized. If the queries >were in the backend, the psql users could keep the \dS command but it >would call an internal function or execute a queried stored in the >system tables. > > > > I just independently had this idea, so I like it :-) cheers andrew
Re: psql \d option list overloaded
От:
Greg Stark <gsstark@mit.edu>
Дата:
Dennis Björklund writes: > I would rather have long commands so one can write > > \describe_table foo I would think it would be better to keep everything under a single command and have a 1-1 correspondence to \d. Ie, just add a long form syntax following the existing \d. \d would become just an obvious set of abbreviations. So for example: \describe table foo => \dt foo \describe index foo => \di foo \describe aggregate foo => \da foo \describe operator foo => \do foo ... -- greg
Re: psql \d option list overloaded
От:
"William ZHANG" <uniware_at_zedware_dot_org@antispam.com>
Дата:
I think moving the \d and simliar features in psql to SQL is a good idea. That will make the features available in any client library. As for the syntax, maybe a investigation is needed.
Re: psql \d option list overloaded
От:
Dennis Björklund <db@zigo.dhs.org>
Дата:
On Sat, 10 Jan 2004, Peter Eisentraut wrote: > > to remember way of showing the various entities in psql (at the very > > least) would be of great advantage. It's something that MySQL gets > > right. As it turns out, we already have "SHOW" in psql and it's used > > for something else. > > What is wrong with > > SELECT * FROM information_schema.tables; The result is very hard to read since it's so much of it (try column instead of tables). The \xx commands do some nice formatting you don't get from the above. I would rather have long commands so one can write \describe_table foo and have the tab completion work for these of course (only for the long commands, the \dt and such does not belong in completion). The information schema is nice, but it's not what I want to use at the prompt to view the content of the database. -- /Dennis Björklund
Re: psql \d option list overloaded
От:
Dennis Bjorklund <db@zigo.dhs.org>
Дата:
On Sun, 11 Jan 2004, Peter Eisentraut wrote: > Another problem with pushing psql's queries into the backend is that > much of the output that psql makes is not a single table. Sometimes > there is more than one table, or the information is in the table > footers. Yes, pushing the \xx commands into the server makes no sense to me at all. The commands in psql are very specific for psql. I don't see why you ever want to do SHOW TABLES except at the command line in psql. If your application wants to find all tables in the database, then we have the standard sql way, which is the information schema. The argument that "show tables" is easier to remember then \dt might be true, but to me that just means that we should make psql better by adding \describe_table and such, not to push psql code into the server. Making a couple of views that are pg specific to make it easier to get information out could be good however. The information schema does not always contain all information one might want. Making specialised SQL commands for it I'm not in favor of at all. -- /Dennis Björklund
Re: psql \d option list overloaded
От:
Jon Jensen <jon@endpoint.com>
Дата:
On Sat, 10 Jan 2004, Tom Lane wrote: > ISTM there are three fundamental problems with \d and friends: > > 1. Some people have a hard time remembering the commands. > 2. Some people aren't using psql. > 3. psql keeps breaking across backend versions because the > needed commands change. > > I don't see a lot of value in addressing just one of these problem > areas, when we could instead do something that addresses all three. I agree, at least for #2 and #3. But I just don't understand #1. Anything is hard to remember when you're just starting to learn it. But it's still faster to type \? then \dt than it is to type "show tables". And "show tables" is hard (relatively speaking) for me to remember because I'm used to psql's way of doing things, since I mostly use it. Jon