Thread: defining yuor own commands in PG ?

defining yuor own commands in PG ?

From
"Gauthier, Dave"
Date:

Can you define your own commands in PG.  E.g., if users from other DBs use “describe foo” to get the metadata for foo, is there a way I can create a command “describe” to = “\d” ?

 

Thanks in Advance

Re: defining yuor own commands in PG ?

From
Filip Rembiałkowski
Date:

2009/12/18 Gauthier, Dave <dave.gauthier@intel.com>

Can you define your own commands in PG. 

In psql, yes:

\set sel 'SELECT * FROM'
:sel clients;

\set desc '\\d'
:desc table

 

E.g., if users from other DBs use “describe foo” to get the metadata for foo, is there a way I can create a command “describe” to = “\d” ?


But what's wrong with "\d"? For me, its like the first thing people learn when practicing postgres.
It is even faster to type than DESCRIBE, right?

IMO, when you will bend postgres to mimick other DBMS, you will hide its real power from users.



--
Filip Rembiałkowski
JID,mailto:filip.rembialkowski@gmail.com
http://filip.rembialkowski.net/

Re: defining yuor own commands in PG ?

From
"Gauthier, Dave"
Date:

THere’s nothing wrong with \d. I prefer it.  I really like \? to get all the ‘\’ commands.  It’s a great system.  But I’m in a position of having to calm potential  MySQL users who are nervous about “different” commands.  I think once they get to know the ‘\’ commands, they’ll be fine.  But for now, just being able to say that I can reproduce their familiar commands will e a selling pitch.

 

Great info to be used for this, and I can see other stuff for my own utility too.

 

Thanks !

 


From: Filip Rembiałkowski [mailto:plk.zuber@gmail.com]
Sent: Saturday, December 19, 2009 7:00 AM
To: Gauthier, Dave
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] defining yuor own commands in PG ?

 

 

2009/12/18 Gauthier, Dave <dave.gauthier@intel.com>

Can you define your own commands in PG. 

In psql, yes:

\set sel 'SELECT * FROM'
:sel clients;

\set desc '\\d'
:desc table

 

E.g., if users from other DBs use “describe foo” to get the metadata for foo, is there a way I can create a command “describe” to = “\d” ?


But what's wrong with "\d"? For me, its like the first thing people learn when practicing postgres.
It is even faster to type than DESCRIBE, right?

IMO, when you will bend postgres to mimick other DBMS, you will hide its real power from users.


--
Filip Rembiałkowski
JID,mailto:filip.rembialkowski@gmail.com
http://filip.rembialkowski.net/

Re: defining yuor own commands in PG ?

From
Israel Brewster
Date:

On Dec 19, 2009, at 2:59 AM, Filip Rembiałkowski wrote:


2009/12/18 Gauthier, Dave <dave.gauthier@intel.com>

Can you define your own commands in PG. 

In psql, yes:

\set sel 'SELECT * FROM'
:sel clients;

\set desc '\\d'
:desc table

 

E.g., if users from other DBs use “describe foo” to get the metadata for foo, is there a way I can create a command “describe” to = “\d” ?


But what's wrong with "\d"? For me, its like the first thing people learn when practicing postgres.
It is even faster to type than DESCRIBE, right?

Just to put in my 2¢, I write a program that can use a MySQL, PostgreSQL, or SQLite database as its backend, depending on user preference. As a result, I spend time in all three databases each day. It can get a bit confusing at times trying to remember "ok, in this terminal window I need to do a 'describe foo', in that one I need to do a '\d foo' and in the third '.schema foo'". So being able to simplify that at least somewhat is nice :) That said, I'd be just as happy getting MySQL to recognize the \d command as I would be getting postgres to recognize describe-perhaps more so.


IMO, when you will bend postgres to mimick other DBMS, you will hide its real power from users.



--
Filip Rembiałkowski
JID,mailto:filip.rembialkowski@gmail.com
http://filip.rembialkowski.net/

-----------------------------------------------
Israel Brewster
Computer Support Technician II
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------


Attachment

Re: defining yuor own commands in PG ?

From
Pavel Stehule
Date:
2009/12/21 Israel Brewster <israel@frontierflying.com>:
>
> On Dec 19, 2009, at 2:59 AM, Filip Rembiałkowski wrote:
>
> 2009/12/18 Gauthier, Dave <dave.gauthier@intel.com>
>>
>> Can you define your own commands in PG.
>
> In psql, yes:
>
> \set sel 'SELECT * FROM'
> :sel clients;
>
> \set desc '\\d'
> :desc table
>
>
>>
>> E.g., if users from other DBs use “describe foo” to get the metadata for
>> foo, is there a way I can create a command “describe” to = “\d” ?
>
> But what's wrong with "\d"? For me, its like the first thing people learn
> when practicing postgres.
> It is even faster to type than DESCRIBE, right?
>
> Just to put in my 2¢, I write a program that can use a MySQL, PostgreSQL, or
> SQLite database as its backend, depending on user preference. As a result, I
> spend time in all three databases each day. It can get a bit confusing at
> times trying to remember "ok, in this terminal window I need to do a
> 'describe foo', in that one I need to do a '\d foo' and in the third
> '.schema foo'". So being able to simplify that at least somewhat is nice :)
> That said, I'd be just as happy getting MySQL to recognize the \d command as
> I would be getting postgres to recognize describe-perhaps more so.
>

do you know gnome-db console?

http://blogs.gnome.org/vivien/2007/10/25/sql-console/
http://library.gnome.org/devel/libgda/unstable/gda-sql-manual-run.html

regards
Pavel

> IMO, when you will bend postgres to mimick other DBMS, you will hide its
> real power from users.
>
>
>
> --
> Filip Rembiałkowski
> JID,mailto:filip.rembialkowski@gmail.com
> http://filip.rembialkowski.net/
>
> -----------------------------------------------
> Israel Brewster
> Computer Support Technician II
> Frontier Flying Service Inc.
> 5245 Airport Industrial Rd
> Fairbanks, AK 99709
> (907) 450-7250 x293
> -----------------------------------------------
>
>
>
>

Re: defining yuor own commands in PG ?

From
Israel Brewster
Date:
On Dec 21, 2009, at 9:34 AM, Pavel Stehule wrote:

> 2009/12/21 Israel Brewster <israel@frontierflying.com>:
>>
>> On Dec 19, 2009, at 2:59 AM, Filip Rembiałkowski wrote:
>>
>> 2009/12/18 Gauthier, Dave <dave.gauthier@intel.com>
>>>
>>> Can you define your own commands in PG.
>>
>> In psql, yes:
>>
>> \set sel 'SELECT * FROM'
>> :sel clients;
>>
>> \set desc '\\d'
>> :desc table
>>
>>
>>>
>>> E.g., if users from other DBs use “describe foo” to get the
>>> metadata for
>>> foo, is there a way I can create a command “describe” to =
>>> “\d” ?
>>
>> But what's wrong with "\d"? For me, its like the first thing people
>> learn
>> when practicing postgres.
>> It is even faster to type than DESCRIBE, right?
>>
>> Just to put in my 2¢, I write a program that can use a MySQL,
>> PostgreSQL, or
>> SQLite database as its backend, depending on user preference. As a
>> result, I
>> spend time in all three databases each day. It can get a bit
>> confusing at
>> times trying to remember "ok, in this terminal window I need to do a
>> 'describe foo', in that one I need to do a '\d foo' and in the third
>> '.schema foo'". So being able to simplify that at least somewhat is
>> nice :)
>> That said, I'd be just as happy getting MySQL to recognize the \d
>> command as
>> I would be getting postgres to recognize describe-perhaps more so.
>>
>
> do you know gnome-db console?

That looks very handy. Of course, I'm using a Mac, no linux, so it may
not work for me, but I'll have to see if I can get it to compile and
run for me. Thanks for the pointer!

>
> http://blogs.gnome.org/vivien/2007/10/25/sql-console/
> http://library.gnome.org/devel/libgda/unstable/gda-sql-manual-run.html
>
> regards
> Pavel
>
>> IMO, when you will bend postgres to mimick other DBMS, you will
>> hide its
>> real power from users.
>>
>>
>>
>> --
>> Filip Rembiałkowski
>> JID,mailto:filip.rembialkowski@gmail.com
>> http://filip.rembialkowski.net/
>>
>> -----------------------------------------------
>> Israel Brewster
>> Computer Support Technician II
>> Frontier Flying Service Inc.
>> 5245 Airport Industrial Rd
>> Fairbanks, AK 99709
>> (907) 450-7250 x293
>> -----------------------------------------------
>>
>>
>>
>>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

-----------------------------------------------
Israel Brewster
Computer Support Technician II
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------




Attachment