Re: Inquiry From Form [pgsql]

From: Will Trillich <will(at)serensoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Inquiry From Form [pgsql]
Date: 2003-02-18 03:24:40
Message-ID: 20030218032440.GC1768@mail.serensoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Feb 15, 2003 at 09:55:07AM +0100, Emmanuel Charpentier wrote:
> Chris wrote:
> >how can I run a SQL script from a text file from within PSQL.
> >
> >Like in Oracle from SQLPlus I would use the @scriptname.sql from the SQL
> >prompt. What is the syntax from PSQL?
>
> \? would have told you that \! <script path and filename> would do the job

not from what i can see:

db> \?
\a toggle between unaligned and aligned output mode
\c[onnect] [DBNAME|- [USER]]
connect to new database (currently "r")
\C TITLE set table title
\cd [DIRNAME] change the current working directory
\copy ... perform SQL COPY with data stream to the client host
\copyright show PostgreSQL usage and distribution terms
\d TABLE describe table (or view, index, sequence)
\d{t|i|s|v}... list tables/indexes/sequences/views
\d{p|S|l} list access privileges, system tables, or large objects
\da list aggregate functions
\dd NAME show comment for table, type, function, or operator
\df list functions
\do list operators
\dT list data types
\e FILENAME edit the current query buffer or file with external editor
\echo TEXT write text to standard output
\encoding ENCODING set client encoding
\f STRING set field separator
\g FILENAME send SQL command to server (and write results to file or |pipe)
\h NAME help on syntax of SQL commands, * for all commands
\H toggle HTML output mode (currently off)
\i FILENAME execute commands from file
\l list all databases
\lo_export, \lo_import, \lo_list, \lo_unlink
large object operations
\o FILENAME send all query results to file or |pipe
\p show the content of the current query buffer
\pset VAR set table output option (VAR := {format|border|expanded|
fieldsep|null|recordsep|tuples_only|title|tableattr|pager})
\q quit psql
\qecho TEXT write text to query output stream (see \o)
\r reset (clear) the query buffer
\s FILENAME print history or save it to file
\set NAME VALUE set internal variable
\t show only rows (currently off)
\T TEXT set HTML table tag attributes
\unset NAME unset (delete) internal variable
\w FILENAME write current query buffer to file
\x toggle expanded output (currently off)
\z list table access privileges
\! [COMMAND] execute command in shell or start interactive shell

here's the pertinent info:

\i FILENAME execute commands from file

whereas

\! [COMMAND] execute command in shell or start interactive shell

says that you can be in psql, database-ing away, and then
quickly do something like

db> \!ls -l

or

db> \!mv somefile somefile.xyzpdq

but it's usually just as easy to ^Z out, frob yuor stuff, and
then % to get back in.

also note that \h gives lots of helpful pointers on using the
actual sql commands.

db> \h
db> \h alter
db> \h create
db> \h create index

--
There are 10 kinds of people:
ones that get binary, and ones that don't.

will(at)serensoft(dot)com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Looking for a firewall? Do you think smoothwall sucks? You're
probably right... Try the folks at http://clarkconnect.org/ !

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dennis Gearon 2003-02-18 03:39:23 Re: TIMESTAMP WITH( OUT)? TIME ZONE indexing/type choice...
Previous Message Dima Tkach 2003-02-18 03:24:19 Re: Index not used with IS NULL